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 » Push button by keystroke (without ALT)
Re: Push button by keystroke (without ALT) [message #29923 is a reply to message #29920] Tue, 30 November 2010 11:31 Go to previous messageGo to previous message
dolik.rce is currently offline  dolik.rce
Messages: 1791
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

Hi Julian,
welcome here Wink

You can trigger the button action from a Key() handler of your application. Have a look at its description in Ctrl reference.

A simple example would be:
#include <CtrlLib/CtrlLib.h>
using namespace Upp;

class Win: public TopWindow{
	typedef Win CLASSNAME;
public:
	Button b;
	Win(){
		Add(b.HCenterPos().VCenterPos());
		b.SetLabel("Close");
		b<<=THISBACK(OnPush);
	}
	void OnPush(){
		Exclamation("Button pushed, exiting...");
		Close();
	}
	bool Key(dword key,int){
		if(key=='q'){
			b.Action();
			return true;
		}
		return false;
	}
};

GUI_APP_MAIN{
	Win().Run();
}


Another possible solution could use InstallKeyHook() which works for entire app, not only one window. It is documented in the same document.

Best regards,
Honza
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: How to center the top most window?
Next Topic: printing RichEditWithToolBar rotated 90 degrees?
Goto Forum:
  


Current Time: Fri Jun 06 13:44:43 CEST 2025

Total time taken to generate the page: 0.04150 seconds