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   |
|
Hi Julian,
welcome here 
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
|
|
|
Goto Forum:
Current Time: Fri Jun 06 13:44:43 CEST 2025
Total time taken to generate the page: 0.04150 seconds
|