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
run function from user control to other control [message #6097] Mon, 30 October 2006 13:57 Go to next message
djesus is currently offline  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 #6098 is a reply to message #6097] Mon, 30 October 2006 14:13 Go to previous messageGo to next message
fallingdutch is currently offline  fallingdutch
Messages: 258
Registered: July 2006
Experienced Member
what do you want to do?

i am sorry but i don't understand what you are trying to do when you are in the LostFocus function.

Bas
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 next message
mirek is currently offline  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 Wink

Mirek
Re: run function from user control to other control [message #6104 is a reply to message #6097] Mon, 30 October 2006 18:09 Go to previous message
djesus is currently offline  djesus
Messages: 14
Registered: September 2006
Promising Member
Sorry for my bad english Embarassed

Thanks a lot Mirek I was exactly asking that.

[Updated on: Mon, 30 October 2006 18:09]

Report message to a moderator

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


Current Time: Sat Apr 20 04:37:28 CEST 2024

Total time taken to generate the page: 0.04342 seconds