Hi All,
I would like to have shortcut to command which is on some button. Is it possible? and how to implement it? thanks!
regards
James
How to have shortcut to command which is on some button Topic is solved
-
- Knows some wx things
- Posts: 38
- Joined: Wed Aug 02, 2006 4:59 am
Re: How to have shortcut to command which is on some button
Hi!
You might also try with wxKeyEvent.
Maybe wxWindow::RegisterHotKey() could help. Note that this would register a system wide hotkey, so your app would respond even if it isn't focused or active.james.chengguangwang wrote:I would like to have shortcut to command which is on some button. Is it possible? and how to implement it?
You might also try with wxKeyEvent.
OS: OpenSuSE, Ubuntu, Win XP Pro
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4
"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4
"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda
-
- Knows some wx things
- Posts: 38
- Joined: Wed Aug 02, 2006 4:59 am
Hi upCASE,
I have found a method to implement it as follows:
And when I press the O key, the OnOK function will be invoked, but I still have a question that I want to let the 'O' character be underlined, sorry for my poor english ability, how can I do it? I mean only the 'O' character is underlined, thanks in advance!
thanks
James[/code]
I have found a method to implement it as follows:
Code: Select all
m_XXX = new wxButton(this, ID_OK_BUTTON, wxT("&OK"));
thanks
James[/code]
Hi!
You mean like a menu accelerator, right?
I'm not really sure about this, but when using something like "&OK" it should display an underlined "O". Maybe this is influenced somehow by system themes...
You mean like a menu accelerator, right?
I'm not really sure about this, but when using something like "&OK" it should display an underlined "O". Maybe this is influenced somehow by system themes...
OS: OpenSuSE, Ubuntu, Win XP Pro
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4
"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4
"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda
Try wxAcceleratorTable. It allows you to link almost any key combination. This example links Esc key with cancel button. Just put it in your window constructor.
Code: Select all
m_button24 = new wxButton( this, ID_CANCEL, _("Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
wxAcceleratorEntry accel_entries[1];
accel_entries[0].Set(wxACCEL_NORMAL,WXK_ESCAPE,ID_CANCEL);
wxAcceleratorTable accel(1, accel_entries);
SetAcceleratorTable(accel);