cannot catch key event in wxSpinCtrlDouble Topic is solved

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
mael15
Super wx Problem Solver
Super wx Problem Solver
Posts: 449
Joined: Fri May 22, 2009 8:52 am
Location: Bremen, Germany

cannot catch key event in wxSpinCtrlDouble

Post by mael15 » Sun Jun 28, 2020 10:51 am

I need to catch the Escape key and assign a specific action in a wxSpinCtrlDouble. Strangly, what works in a wxSpinCtrl does not in a wxSpinCtrlDouble:

Code: Select all

class escTest : public wxSpinCtrl/*Double*/ {
public:
	escTest(wxWindow *par) : wxSpinCtrl/*Double*/(par, wxID_ANY){
		Bind(wxEVT_KEY_DOWN, wxKeyEventHandler(escTest::onKeyDown), this);
	}

	void onKeyDown(wxKeyEvent& evt) {
		int keyCode = evt.GetKeyCode();
		if (keyCode == WXK_ESCAPE) {
			int doSomething = 0;
		}
		evt.Skip();
	}
};
Is there a workaround?

User avatar
doublemax
Moderator
Moderator
Posts: 15264
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: cannot catch key event in wxSpinCtrlDouble

Post by doublemax » Sun Jun 28, 2020 11:05 am

Try catching wxEVT_CHAR
Use the source, Luke!

mael15
Super wx Problem Solver
Super wx Problem Solver
Posts: 449
Joined: Fri May 22, 2009 8:52 am
Location: Bremen, Germany

Re: cannot catch key event in wxSpinCtrlDouble

Post by mael15 » Sun Jun 28, 2020 11:17 am

works perfectly, thanx! =D>

Post Reply