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 » What way is best to implement Callback for GotFocus/LostFocus?
Re: What way is best to implement Callback for GotFocus/LostFocus? [message #11014 is a reply to message #11006] Tue, 14 August 2007 10:58 Go to previous message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
You can actually implement this in a general way quite easily, and without having to derive anything.

Ctrl has two methods, ChildGotFocus and ChildLostFocus, that you can overload in the parent window to catch the event. Then you just have to see if an edit ctrl has the focus:
	virtual void ChildGotFocus() {
		Ctrl *c = GetFocusChild();
		if (!c || !c->IsEditable()) return;
		 
		if (dynamic_cast<EditField *>(c) || dynamic_cast<TextCtrl *>(c)) {
			// Show keyboard
		}
	}

	virtual void ChildLostFocus() {
		// Unless focus has moved to the keyboard, hide it here
	}

You may need to add some other control types, or use
GetFocusChildDeep if you use ArrayCtrls. This is not the only other solution though.

James
 
Read Message
Read Message
Previous Topic: "ScrollArea"...
Next Topic: Is there an equivalent of win32 API "SendMessage" in U++
Goto Forum:
  


Current Time: Wed Aug 06 20:28:22 CEST 2025

Total time taken to generate the page: 0.04479 seconds