KnowBrainer Speech Recognition
Decrease font size
Increase font size
Topic Title: Dialog Boxes, Text Boxes and Accelerator Keys
Topic Summary: How to use an accelerator key to change focus in a dialog box to a text box
Created On: 11/28/2007 05:15 PM
Status: Post and Reply
Linear : Threading : Single : Branch
 Dialog Boxes, Text Boxes and Accelerator Keys   - PG LTU - 11/28/2007 05:15 PM  
Keyword
 11/28/2007 05:15 PM
User is offline View Users Profile Print this message

Author Icon
PG LTU
Top-Tier Member

Posts: 2116
Joined: 03/21/2007

In a Dragon advance scripting macro, in a user-defined dialog box that I have created, I have more than one TextBox which I want to dictate into. I want to access them randomly. I can do it by adding buttons on the dialog box (in which the button action changes the focus and may do other things without exiting the dialog box), and I can do it by using "voice menus" (thanks to G Shields and others on this forum -- but where can I find out more information about voice menus, please?) which also don't exit the dialog box.

Now, I want to do it by using a text label with an accelerator key (an underlined letter by adding an "&" to the text caption). The problem is, no matter how I access the text label (pressing the alt-accelerator key on the keyboard, saying "press alt accelerator" or even just saying the text label itself -- which only works, it seems, if you have an accelerator defined) the dialog box goes away (as if I pressed the "okay" button). Any suggestions?


' sample two boxes
' (C) 2007 PG Service
'
Sub Main
  Dim Result, s ' needed for explicit
' >>>> Dialog Definition
 Begin Dialog TwoBoxDialog 0,0,510,406,"PG Multi-Edit Test",.MultiEdit '' (C) 2007 PG Service %GRID:10,7,1,1
  OKButton 160,378,90,21
  CancelButton 320,378,90,21
  TextBox 100,14,390,133,.TopTextBox,1 'First Box
  TextBox 100,161,390,175,.BottomTextBox,1 'Second Box
  PushButton 10,14,90,21,"Top",.TopPushButton
  PushButton 10,49,90,21,"Top Start",.TopStartPushButton
  PushButton 10,77,90,21,"Top End",.TopEndPushButton
  PushButton 10,161,90,21,"Bottom",.BottomPushButton
  PushButton 10,196,90,21,"Bottom Start",.BottomStartPushButton
  PushButton 10,224,90,21,"Bottom End",.BottomEndPushButton
  Text 10,105,90,14,"&First",.TopText,2
  Text 10,126,90,14,"First Text",.TopText2,2
  Text 10,252,90,14,"&Second",.BottomText,2
  Text 10,280,90,14,"Second Text",.BottomText2,2
  Text 110,343,330,28,"You can also say ""go to top box"" or ""go to bottom box"" to change the focus, or try ""Hello World""",.InstructionText,2
 End Dialog
' <<<< Dialog Definition
 Dim TwoBoxDlg As TwoBoxDialog
 Result = Dialog ( TwoBoxDlg )  '  show dialog (wait for OK)
 If Result = 0 Then s = " (Cancel)"
 If Result = -1 Then s = " (OK)"
 MsgBox ( "This is the result: " & Result & s & Chr(13)&Chr(10) _
   & "Top Box: " & TwoBoxDlg.TopTextBox & Chr(13)&Chr(10) _
   & "Bottom Box: " & TwoBoxDlg.BottomTextBox , vbInformation , "Result of TwoBoxDialog" )
End Sub
Public Sub VoiceCommand_CommandRecognize ( Command As String , ID As Long , Action As String , ListResults As DNSTools.DgnStrings )
 If ID = 1 Then DlgFocus "TopTextBox"  '  set focus to this text box
 If ID = 2 Then DlgFocus "BottomTextBox"  '  set focus to this text box
 If ID = 3 Then MsgBox "You said: ""Hello, World!""",vbInformation, "pgService Two Boxes"  '  show a message box
End Sub
Private Function MultiEdit (DlgItem As String, Action As Integer, SuppValue As Integer) As Boolean
 Static VMenu ' As IVMenuAuto  '  needed for voice menus
 Select Case Action
  Case 1  '  Dialog box initialization
   Set VMenu = VoiceCommand.MenuCreate ("Two Boxes App" , "Two Boxes " , dgnlangUSEnglish , "" , vcmdmc_CREATE_TEMP )
    VMenu.Add 1 , "go to top box" , "" , ""
    VMenu.Add 2 , "go to bottom box" , "" , ""
    Vmenu.Add 3 , "hello world" , "" , ""
    VMenu.Active = True
  Case 2  '  Value changing or button pressed
    If DlgItem$ = "TopPushButton" Then
     MultiEdit = True  '  do not exit the dialog
     DlgFocus "TopTextBox"  '  set focus to this text box
    End If
    If DlgItem$ = "TopStartPushButton" Then
     MultiEdit = True  '  do not exit the dialog
     DlgFocus "TopTextBox"  '  set focus to this text box
     SendKeys "^{Home}"
    End If
    If DlgItem$ = "TopEndPushButton" Then
     MultiEdit = True  '  do not exit the dialog
     DlgFocus "TopTextBox"  '  set focus to this text box
     SendKeys "^{End}"
    End If
    If DlgItem$ = "BottomPushButton" Then
     MultiEdit = True  '  do not exit the dialog
     DlgFocus "BottomTextBox"  '  set focus to this text box
    End If
    If DlgItem$ = "BottomStartPushButton" Then
     MultiEdit = True  '  do not exit the dialog
     DlgFocus "BottomTextBox"  '  set focus to this text box
     SendKeys "^{Home}"
    End If
    If DlgItem$ = "BottomEndPushButton" Then
     MultiEdit = True  '  do not exit the dialog
     DlgFocus "BottomTextBox"  '  set focus to this text box
     SendKeys "^{End}"
    End If
  Case 3  '  TextBox or ComboBox text changed
  Case 4  '  Focus changed
  Case 5  '  Idle
  Case 6  '  Function key
 End Select
End Function

Thanks


-------------------------




PG





Remember folks, my comments and this forum are for entertainment value only, please, no wagering or other reliance on the contents herein.  I permit no commercial use of my ideas (whether expressions or embodiments) without my written consent.



Statistics
31892 users are registered to the KnowBrainer Speech Recognition forum.
There are currently 0 users logged in.
The most users ever online was 12124 on 09/09/2020 at 04:59 AM.
There are currently 597 guests browsing this forum, which makes a total of 597 users using this forum.

FuseTalk Standard Edition v4.0 - © 1999-2021 FuseTalk™ Inc. All rights reserved.