Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Widgets - General questions or Mixed problems » How to set the ***initial*** focus to an option?
How to set the ***initial*** focus to an option? [message #6561] Sat, 18 November 2006 14:29 Go to next message
Werner is currently offline  Werner
Messages: 234
Registered: May 2006
Location: Cologne / Germany
Experienced Member
I have a ParentCtrl and on it, at the top position, an Option. Below that is a Label and an EditField.

When the application starts, the EditField has the focus.

I would like the Option to have the focus, but I don't know how. "SetFocus()" doesn't work in the constructor.

Surprisingly, "SetFocus()" works well, when I move the focus later on ("OnKey()").

How can I set the focus to the (topmost) option, when the application starts?

Werner

Re: How to set the ***initial*** focus to an option? [message #6562 is a reply to message #6561] Sat, 18 November 2006 15:01 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Only widgets visible on the screen can have focus (therefore setting it in the constructor cannot work).

However, each TopWindow remembers the "focused child" and when it gets activated, places (restores) actual focus to it. Note that the main purpose of this is to maintain the expexted user experience.

You can change this "focused child" by calling TopWindow's ActiveFocus with child as parameter. If TopWindows is active ("foreground"), child gets focus immediately, otherwise it gets in once TopWindow gets active.

Short answer: Use ActiveFocus Wink

Mirek
Re: How to set the ***initial*** focus to an option? [message #6564 is a reply to message #6562] Sat, 18 November 2006 15:18 Go to previous messageGo to next message
Werner is currently offline  Werner
Messages: 234
Registered: May 2006
Location: Cologne / Germany
Experienced Member
luzr wrote on Sat, 18 November 2006 15:01

...

Short answer: Use ActiveFocus Wink

Mirek



My "work paradigm" forces me, at first to dig instead of to ask. Confused

I shouldn't ... Rolling Eyes

Thank you.

Werner

Re: How to set the ***initial*** focus to an option? [message #6572 is a reply to message #6564] Sun, 19 November 2006 10:06 Go to previous messageGo to next message
fallingdutch is currently offline  fallingdutch
Messages: 258
Registered: July 2006
Experienced Member
Hello Werner,
if you use the Layout Editor just change the order of the Ctrls - the topmost Control with the value want's focus gets it at first and the next in the list is selected when pressing tab

Bas
Re: How to set the ***initial*** focus to an option? [message #6573 is a reply to message #6572] Sun, 19 November 2006 11:36 Go to previous message
Werner is currently offline  Werner
Messages: 234
Registered: May 2006
Location: Cologne / Germany
Experienced Member
Thanks.

I'm working on quite a complicated UPT where using the layout editor is not appropriate. But Mirek's answer "Use ActiveFocus" already solved the problem (refer to message #6562).

Werner

Previous Topic: first row strange behaviour in columnlist
Next Topic: DropList bug
Goto Forum:
  


Current Time: Sat Apr 20 04:19:30 CEST 2024

Total time taken to generate the page: 3.17250 seconds