Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Where to setfocus()?
Message
From
17/08/2004 10:10:16
Dragan Nedeljkovich
Now officially retired
Zrenjanin, Serbia
 
 
To
16/08/2004 18:31:10
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00931180
Message ID:
00933812
Views:
23
This message has been marked as a message which has helped to the initial question of the thread.
>>>Is there a better way in general of setting the control which is to receive initial focus at run-time? There are many examples of why you would want to do this, eg using the same form for adding a new record and editing an existing record. In the case of adding you would want the first user editable control (say a textbox) to be selected. In the case of editing you would want the OK button selected.
>>
>>How about setting the tab order for all other controls to something higher (maybe you can do that in design mode), and have the optiongroup have taborder=1? That should give it the focus without any extra action.
>
>The option group has the focus BUT the first option button has the actual focus not the option button that I wish to have focus. If the user presses say "spacebar" the option with the dotted line around it (the first) not the option which is selected, gets "pressed". Even setting "value" doesn't help.

I've tried this in form's .gotfocus():

this.optiongroup1.Buttons[this.optiongroup1.value].setfocus

and it worked, but in general case this is still bad, because the form may have lost focus when you had any other control having focus, so restoring focus to your form would always return focus to the optiongroup. Ideally, if optiongroup had a .gotfocus event, that would be the best place to put the above command, but it doesn't.

So, the trick is to put the optiongroup into a container, which does have a .gotfocus, and the command to set the focus to the correct optionbutton goes there. Tried, works.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform