Trapping "Ctrl + F1" in a Dialog based application

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
AmitK
Knows some wx things
Knows some wx things
Posts: 48
Joined: Mon Dec 12, 2005 6:18 am

Trapping "Ctrl + F1" in a Dialog based application

Post by AmitK » Tue Jan 10, 2006 11:16 am

Hi All.

I have a dialog based application and would like to trap "Ctrl + F1" and F1 keys, but my problem is wxAcceleratorEntry is not working in dialog derived classes.

Can anyone tell me, How to Proceed and What approach to follow?

Thanks and Regards.
AmitK

Bundy
I live to help wx-kind
I live to help wx-kind
Posts: 153
Joined: Fri Apr 29, 2005 9:46 am
Location: Poland

Post by Bundy » Wed Jan 11, 2006 11:25 am

Maybe this example helps You:

Code: Select all

BEGIN_EVENT_TABLE(myframe,wxDialog)
	EVT_KEY_DOWN(myframe::on_escape)
END_EVENT_TABLE()


void myframe::on_escape(wxKeyEvent& event)
{
	if( event.GetKeyCode() == 27 )
	{
	    EndModal(wxID_CANCEL);
	    Destroy();
	}    
	event.Skip();
}

You can change 27 to WXK_F1 for intercepting F1 button,

when You need to check it user also hit Control (or Command on Mack) just check that event.CmdDown() function returns true :)

Regards
Bundy
"Fate rewards prepared mind"

Quote from movie "Liberator 2"

Post Reply