mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-08-17 15:11:56 -06:00
FIX: button handle key event
Change-Id: If3ecd2356e516105c2054c9b85a122f3ccc72d91
This commit is contained in:
parent
6c4b1f79da
commit
a74fb14613
6 changed files with 59 additions and 9 deletions
|
@ -7,6 +7,8 @@ BEGIN_EVENT_TABLE(Button, StaticBox)
|
|||
|
||||
EVT_LEFT_DOWN(Button::mouseDown)
|
||||
EVT_LEFT_UP(Button::mouseReleased)
|
||||
EVT_KEY_DOWN(Button::keyDownUp)
|
||||
EVT_KEY_UP(Button::keyDownUp)
|
||||
|
||||
// catch paint events
|
||||
EVT_PAINT(Button::paintEvent)
|
||||
|
@ -241,9 +243,46 @@ void Button::mouseReleased(wxMouseEvent& event)
|
|||
}
|
||||
}
|
||||
|
||||
void Button::keyDownUp(wxKeyEvent &event)
|
||||
{
|
||||
if (event.GetKeyCode() == WXK_SPACE || event.GetKeyCode() == WXK_RETURN) {
|
||||
wxMouseEvent evt(event.GetEventType() == wxEVT_KEY_UP ? wxEVT_LEFT_UP : wxEVT_LEFT_DOWN);
|
||||
event.SetEventObject(this);
|
||||
GetEventHandler()->ProcessEvent(evt);
|
||||
return;
|
||||
}
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
void Button::sendButtonEvent()
|
||||
{
|
||||
wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, GetId());
|
||||
event.SetEventObject(this);
|
||||
GetEventHandler()->ProcessEvent(event);
|
||||
}
|
||||
|
||||
#ifdef __WIN32__
|
||||
|
||||
WXLRESULT Button::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
|
||||
{
|
||||
if (nMsg == WM_GETDLGCODE) { return DLGC_WANTMESSAGE; }
|
||||
if (nMsg == WM_KEYDOWN) {
|
||||
wxKeyEvent event(CreateKeyEvent(wxEVT_KEY_DOWN, wParam, lParam));
|
||||
switch (wParam) {
|
||||
case WXK_RETURN: {
|
||||
GetEventHandler()->ProcessEvent(event);
|
||||
return 0;
|
||||
}
|
||||
case WXK_TAB:
|
||||
case WXK_LEFT:
|
||||
case WXK_RIGHT:
|
||||
case WXK_UP:
|
||||
case WXK_DOWN:
|
||||
if (HandleAsNavigationKey(event))
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return wxWindow::MSWWindowProc(nMsg, wParam, lParam);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue