I imagine the focus to your edit box is happening prior to the default focus to
the close button. Try queuing your control manipulation by doing something like:
If DEvent = DialogCreated Then
Queue "DialogInit", dObj
. . .
Sub DialogInit(dObj)
dObj.Control( "Box1" ).Text = FormatNumber( "2764.2345")
dObj.Control( "Box2" ).Focus()
End Sub
Aaron
--
Aaron Smith
Product Development & Integration
Ai Squared
130 Taconic Business Park Rd
Manchester Center, VT 05255
(802) 362-3612 x 208
[email protected]
www.aisquared.com
> -----Original Message-----
> From: Scripting [mailto:scripting-
> [email protected]] On Behalf Of
> David via Scripting
> Sent: Friday, September 30, 2016 8:37 AM
> To: GWScripting <[email protected]>
> Subject: Trouble in focusing an Editbox
>
> Have a dialog screen, made up of two Editboxes (Box1 and Box2), along with
> a handful buttons, also a Button texted "Close", and set with the system field
> to CLOSE. All the dialog has been created with UIDesign.
>
> When I open the dialog, I want to have the cursor go directly to the second
> Editbox (Box2), as this is the box where the user-input will take place.
>
> In my Dialog Event Handling function, I therefore made the following lines:
>
> Select Case dID
>
> ...
> Case Else
> If DEvent = DialogCreated Then
> dObj.Control( "Box1" ).Text = FormatNumber( "2764.2345")
> dObj.Control( "Box2" ).Focus
> EHMainDialog = True
> Exit Function
> ElseIf dEvent = dialogClosing Then
> Set DObj = Nothing
> Set DControl = Nothing
> EHMainDialog = True
> End If 'DialogCreated.
> End Select 'Case dId.
>
>
> Issue is, everytime I open the dialog, the cursor lands on the Close-button -
> NOT on the Box2 as I have asked it to. I thought maybe it had to do with the
> Close-button being set to a Close-type button, so have tried to change this
> to anything else, but with same result. The Close-button is not even set to be
> the default button, in my XML dialog.
> Another Button, marked "Speak", has been set to be the default button, but
> still the Close-button is the one that takes focus when the dialog opens.
>
> What could be wrong in my above lines? Does the Focus property not work
> on Editboxes? Or, do I need to do some more programming to have the
> editbox take focus upon opening? Even, is there a workaround for this kind
> of scenario?
>
> Thanks for all feedback. Likely my brain is short today, and the solution
> might
> be simple enough. :)
>
> _______________________________________________
> Any views or opinions presented in this email are solely those of the author
> and do not necessarily represent those of Ai Squared.
>
> For membership options, visit http://lists.window-
> eyes.com/options.cgi/scripting-window-
> eyes.com/asmith%40aisquared.com.
> For subscription options, visit http://lists.window-
> eyes.com/listinfo.cgi/scripting-window-eyes.com
> List archives can be found at http://lists.window-
> eyes.com/private.cgi/scripting-window-eyes.com
_______________________________________________
Any views or opinions presented in this email are solely those of the author
and do not necessarily represent those of Ai Squared.
For membership options, visit
http://lists.window-eyes.com/options.cgi/scripting-window-eyes.com/archive%40mail-archive.com.
For subscription options, visit
http://lists.window-eyes.com/listinfo.cgi/scripting-window-eyes.com
List archives can be found at
http://lists.window-eyes.com/private.cgi/scripting-window-eyes.com