Ejemplo n.º 1
0
void KeyMonitorTextCtrl::OnKey(wxKeyEvent &event)
{
	if(event.GetKeyCode() != 308){
		//printf("key:%d %d\n", event.GetKeyCode(), event.GetModifiers());
	}
    // backspace cannot be used as shortcut key...
    if (event.GetKeyCode() == WXK_BACK)
    {
        // this text ctrl contains something and the user pressed backspace...
        // we must delete the keypress...
        Clear();
        return;
    }

    if (event.GetEventType() == wxEVT_KEY_DOWN ||
        (event.GetEventType() == wxEVT_KEY_UP && !IsValidKeyComb()))
    {
        // the user pressed some key combination which must be displayed
        // in this text control.... or he has just stopped pressing a
        // modifier key like shift, ctrl or alt without adding any
        // other alphanumeric char, thus generating an invalid keystroke
        // which must be cleared out...

        KeyBinder::Key key;
        key.code    = event.GetKeyCode();
        key.flags   = event.GetModifiers();
		
        SetValue(KeyBinder::GetKeyBindingAsText(key));
        SetInsertionPointEnd();

    }

}
Ejemplo n.º 2
0
void wxKeyMonitorTextCtrl::OnKey(wxKeyEvent &event)
{
    // backspace cannot be used as shortcut key...
#ifndef wxKEYBINDER_ALLOW_BACKSPACE
    if (event.GetKeyCode() == WXK_BACK) {

        // this text ctrl contains something and the user pressed backspace...
        // we must delete the keypress...
        Clear();
        return;
    }
#endif

    if (event.GetEventType() == wxEVT_KEY_DOWN ||
            (event.GetEventType() == wxEVT_KEY_UP && !IsValidKeyComb())) {

        // the user pressed some key combination which must be displayed
        // in this text control.... or he has just stopped pressing a
        // modifier key like shift, ctrl or alt without adding any
        // other alphanumeric char, thus generating an invalid keystroke
        // which must be cleared out...
        SetValue(wxKeyBind::GetKeyStrokeString(event));
        SetInsertionPointEnd();
    }
}