Home » U++ Library support » U++ Widgets - General questions or Mixed problems » run function from user control to other control
run function from user control to other control [message #6097] |
Mon, 30 October 2006 13:57 |
djesus
Messages: 14 Registered: September 2006
|
Promising Member |
|
|
Hi, I have made a user control named myctrl. It has a method LostFocus(), from this method I would like to access to a function of the CtrlLayout.
There is any way to do this?
Thanks a lot.
|
|
|
|
Re: run function from user control to other control [message #6099 is a reply to message #6097] |
Mon, 30 October 2006 14:32 |
|
mirek
Messages: 13975 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
Mirek
|
|
|
|
Goto Forum:
Current Time: Sat Apr 20 04:37:28 CEST 2024
Total time taken to generate the page: 0.04342 seconds
|