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 » run function from user control to other control
Re: run function from user control to other control [message #6099 is a reply to message #6097] Mon, 30 October 2006 14:32 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 14261
Registered: November 2005
Ultimate Member
I think you want to connect that LostFocus to the same method of your dialog, right?

Well, the most generic way is to provide your Ctrl with Callback, like WhenLostFocus, then call this Callback in LostFocus function. In your dialog, assign a dialog's method to the Callback.

Alternatively, if this Ctrl is only about to be used in this single dialog, you could also simply downcast GetParent and call the method directly - a bit ugly, less safe, but would work too.

I think you was asking about this issue yesterday. Meanwhile I was thinking about the problem and there is another quite simple (but not quite straightforward) solution - override your dialog's ChildGotFocus to store focus in some dialog's member variable, then override ChildLostFocus and test whether this variable equals your widget:

struct MyDialog {
   Ctrl *lastfocus;
   virtual void ChildGotFocus() { lastfocus = GetFocusCtrl(); }
   virtual void ChildLostFocus() { if(lastfocus == &mywidget) { ... } }
};


Of course, it all depends on what moving that focus out is really supposed to do Wink

Mirek
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: easiest way to convert a Topwindow into a control
Next Topic: Focus problem
Goto Forum:
  


Current Time: Sun Jun 08 16:57:29 CEST 2025

Total time taken to generate the page: 0.04875 seconds