Hotkey editor code tweaking
This commit is contained in:
parent
97a7330e80
commit
a153b25411
|
@ -95,6 +95,10 @@ void HOTKEYS_EDITOR_DIALOG::CancelClicked( wxCommandEvent& event )
|
||||||
void HOTKEYS_EDITOR_DIALOG::UndoClicked( wxCommandEvent& event )
|
void HOTKEYS_EDITOR_DIALOG::UndoClicked( wxCommandEvent& event )
|
||||||
{
|
{
|
||||||
m_table->RestoreFrom( m_hotkeys );
|
m_table->RestoreFrom( m_hotkeys );
|
||||||
|
m_curEditingRow = -1;
|
||||||
|
for( int i = 0; i < m_hotkeyGrid->GetNumberRows(); ++i )
|
||||||
|
SetHotkeyCellState( i, false );
|
||||||
|
|
||||||
m_hotkeyGrid->Refresh();
|
m_hotkeyGrid->Refresh();
|
||||||
Update();
|
Update();
|
||||||
}
|
}
|
||||||
|
@ -167,7 +171,7 @@ void HOTKEYS_EDITOR_DIALOG::KeyPressed( wxKeyEvent& event )
|
||||||
if( key >= 'a' && key <= 'z' ) //upcase key
|
if( key >= 'a' && key <= 'z' ) //upcase key
|
||||||
key = key + ('A' - 'a');
|
key = key + ('A' - 'a');
|
||||||
|
|
||||||
#if 0 // For debug
|
#if 0 // For debug only
|
||||||
wxString msg;
|
wxString msg;
|
||||||
msg.Printf(wxT("key %X, keycode %X"),event.GetKeyCode(), key);
|
msg.Printf(wxT("key %X, keycode %X"),event.GetKeyCode(), key);
|
||||||
wxMessageBox(msg);
|
wxMessageBox(msg);
|
||||||
|
@ -175,12 +179,11 @@ void HOTKEYS_EDITOR_DIALOG::KeyPressed( wxKeyEvent& event )
|
||||||
// See if this key code is handled in hotkeys list
|
// See if this key code is handled in hotkeys list
|
||||||
bool exists;
|
bool exists;
|
||||||
ReturnKeyNameFromKeyCode( key, &exists );
|
ReturnKeyNameFromKeyCode( key, &exists );
|
||||||
if( !exists ) // not handled, see s_Hotkey_Name_List[] in hotkeys_basic.cpp
|
if( !exists ) // not handled, see hotkeys_basic.cpp
|
||||||
wxMessageBox( _("Hotkey value not handled" ) );
|
wxMessageBox( _("Hotkey code not handled" ) );
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_table->SetKeyCode( m_curEditingRow, key );
|
m_table->SetKeyCode( m_curEditingRow, key );
|
||||||
SetHotkeyCellState( m_curEditingRow, false );
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,6 +106,10 @@ static struct hotkey_name_descr s_Hotkey_Name_List[] =
|
||||||
{ wxT( "" ), 0 }
|
{ wxT( "" ), 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define MODIFIER_CTRL wxT( "Ctrl+" )
|
||||||
|
#define MODIFIER_ALT wxT( "Alt+" )
|
||||||
|
#define MODIFIER_SHIFT wxT( "Shift+" )
|
||||||
|
|
||||||
|
|
||||||
/** function ReturnKeyNameFromKeyCode
|
/** function ReturnKeyNameFromKeyCode
|
||||||
* return the key name from the key code
|
* return the key name from the key code
|
||||||
|
@ -122,11 +126,11 @@ wxString ReturnKeyNameFromKeyCode( int aKeycode, bool* aIsFound )
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
if( (aKeycode & GR_KB_CTRL) != 0 )
|
if( (aKeycode & GR_KB_CTRL) != 0 )
|
||||||
modifier << wxT( "Ctrl+" );
|
modifier << MODIFIER_CTRL;
|
||||||
if( (aKeycode & GR_KB_ALT) != 0 )
|
if( (aKeycode & GR_KB_ALT) != 0 )
|
||||||
modifier << wxT( "Alt+" );
|
modifier << MODIFIER_ALT;
|
||||||
if( (aKeycode & GR_KB_SHIFT) != 0 )
|
if( (aKeycode & GR_KB_SHIFT) != 0 )
|
||||||
modifier << wxT( "Shift+" );
|
modifier << MODIFIER_SHIFT;
|
||||||
|
|
||||||
aKeycode &= ~( GR_KB_CTRL | GR_KB_ALT | GR_KB_SHIFT );
|
aKeycode &= ~( GR_KB_CTRL | GR_KB_ALT | GR_KB_SHIFT );
|
||||||
|
|
||||||
|
@ -268,18 +272,18 @@ static int ReturnKeyCodeFromKeyName( const wxString& keyname )
|
||||||
int modifier = 0;
|
int modifier = 0;
|
||||||
while( 1 )
|
while( 1 )
|
||||||
{
|
{
|
||||||
if( key.StartsWith(wxT("Ctrl+") ) )
|
if( key.StartsWith( MODIFIER_CTRL ) )
|
||||||
{
|
{
|
||||||
modifier |= GR_KB_CTRL;
|
modifier |= GR_KB_CTRL;
|
||||||
key.Remove( 0, 5 );
|
key.Remove( 0, 5 );
|
||||||
}
|
}
|
||||||
|
|
||||||
else if( key.StartsWith(wxT("Alt+") ) )
|
else if( key.StartsWith( MODIFIER_ALT ) )
|
||||||
{
|
{
|
||||||
modifier |= GR_KB_ALT;
|
modifier |= GR_KB_ALT;
|
||||||
key.Remove( 0, 4 );
|
key.Remove( 0, 4 );
|
||||||
}
|
}
|
||||||
else if( key.StartsWith(wxT("Shift+") ) )
|
else if( key.StartsWith( MODIFIER_SHIFT ) )
|
||||||
{
|
{
|
||||||
modifier |= GR_KB_SHIFT;
|
modifier |= GR_KB_SHIFT;
|
||||||
key.Remove( 0, 6 );
|
key.Remove( 0, 6 );
|
||||||
|
|
Loading…
Reference in New Issue