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 » Help needed to set the focus
Help needed to set the focus [message #21137] Mon, 04 May 2009 21:38 Go to next message
JoseB is currently offline  JoseB
Messages: 37
Registered: March 2009
Member
Hi all,

I have an application which have a menu that each menu option opens a modal dialog.
On the MainApp class file I declare a dialog in this way:

header:
WithSettingsDlgLayout<TopWindow> m_dlgSettings;

cpp:
void MyApp::OnMenuOptionSettings(void)
{
ActiveFocus(m_dlgSettings.edLang);
m_dlgSettings.edLang.SetFocus();

m_dlgSettings.ok<<= THISBACK(OnSettingsOK);
m_dlgSettings.cancel<<= THISBACK(OnSettingsCancel);

m_dlgSettings.Execute();
}

Well, for the first time that the dialog is opened, focus is on the edLang edit box, but if the focus is in other edit box
when closing the dialog, on the next time the dialog is open the focus is on that edit box and not on the edLang, even executing the
code of OnMenuOptionSettings(void).
It seems that the dialog (m_dlgSettings) saves state.
Do I have to clear the state when closing the dialog?
How to hanlde this?
Should i use ActiveFocus or SetFocus.

I tried to put

ActiveFocus(m_dlgSettings.edLang);
m_dlgSettings.edLang.SetFocus();

before the Close call (to close the dialog) but it doesnt work.

Should I use a pointer instead of a class member variable and destroy the pointer on close()?

It seems that is hard to handle focus.




Thank you


JoseB

[Updated on: Mon, 04 May 2009 21:39]

Report message to a moderator

Re: Help needed to set the focus [message #21139 is a reply to message #21137] Tue, 05 May 2009 00:02 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
JoseB wrote on Mon, 04 May 2009 15:38

Hi all,

I have an application which have a menu that each menu option opens a modal dialog.
On the MainApp class file I declare a dialog in this way:

header:
WithSettingsDlgLayout<TopWindow> m_dlgSettings;

cpp:
void MyApp::OnMenuOptionSettings(void)
{
ActiveFocus(m_dlgSettings.edLang);
m_dlgSettings.edLang.SetFocus();

m_dlgSettings.ok<<= THISBACK(OnSettingsOK);
m_dlgSettings.cancel<<= THISBACK(OnSettingsCancel);

m_dlgSettings.Execute();
}

Well, for the first time that the dialog is opened, focus is on the edLang edit box, but if the focus is in other edit box
when closing the dialog, on the next time the dialog is open the focus is on that edit box and not on the edLang, even executing the
code of OnMenuOptionSettings(void).
It seems that the dialog (m_dlgSettings) saves state.



Yes.

Quote:


Do I have to clear the state when closing the dialog?



Better before opening.

Quote:


How to hanlde this?
Should i use ActiveFocus or SetFocus.

I tried to put

ActiveFocus(m_dlgSettings.edLang);
m_dlgSettings.edLang.SetFocus();



m_dlgSettings.ActiveFocus(m_dlgSettings.edLang);

Smile

ActiveFocus is "focus for TopWindow when it is active". It is member function of TopWindow.

Mirek
Previous Topic: Formating date according to the country
Next Topic: Popup input Dialog
Goto Forum:
  


Current Time: Fri Mar 29 10:26:52 CET 2024

Total time taken to generate the page: 0.01556 seconds