2016-01-16 01:56:57 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2016 Chris Pavlina <pavlina.chris@gmail.com>
|
2023-04-16 21:49:54 +00:00
|
|
|
* Copyright (C) 2016-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2016-01-16 01:56:57 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 3
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2016-01-16 02:07:12 +00:00
|
|
|
#include <cctype>
|
2021-09-20 15:59:18 +00:00
|
|
|
|
|
|
|
#include <confirm.h>
|
2016-01-16 01:56:57 +00:00
|
|
|
#include <widgets/widget_hotkey_list.h>
|
2021-06-06 17:26:26 +00:00
|
|
|
#include <tool/tool_event.h>
|
2016-01-16 01:57:10 +00:00
|
|
|
#include <dialog_shim.h>
|
2021-09-20 15:59:18 +00:00
|
|
|
|
|
|
|
#include <wx/log.h>
|
2020-12-05 01:10:28 +00:00
|
|
|
#include <wx/dcclient.h>
|
2021-09-20 15:59:18 +00:00
|
|
|
#include <wx/menu.h>
|
|
|
|
#include <wx/msgdlg.h>
|
|
|
|
#include <wx/statline.h>
|
2021-06-03 11:49:49 +00:00
|
|
|
#include <wx/stattext.h>
|
2021-09-20 15:59:18 +00:00
|
|
|
#include <wx/treelist.h>
|
2016-01-16 01:56:57 +00:00
|
|
|
|
2016-01-16 01:58:53 +00:00
|
|
|
/**
|
|
|
|
* Menu IDs for the hotkey context menu
|
|
|
|
*/
|
|
|
|
enum ID_WHKL_MENU_IDS
|
|
|
|
{
|
2019-05-26 15:36:40 +00:00
|
|
|
ID_EDIT_HOTKEY = 2001,
|
2023-07-13 14:08:00 +00:00
|
|
|
ID_EDIT_ALT,
|
2016-01-16 01:58:53 +00:00
|
|
|
ID_RESET,
|
2016-03-30 18:51:47 +00:00
|
|
|
ID_DEFAULT,
|
2023-07-13 14:08:00 +00:00
|
|
|
ID_CLEAR,
|
|
|
|
ID_CLEAR_ALT,
|
2016-01-16 01:58:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-01-16 01:56:57 +00:00
|
|
|
/**
|
2020-11-16 22:46:39 +00:00
|
|
|
* Store the hotkey change data associated with each row.
|
|
|
|
*
|
|
|
|
* To change a hotkey, edit it via GetCurrentValue() in the row's client data, then call
|
2018-09-26 14:26:26 +00:00
|
|
|
* WIDGET_HOTKEY_LIST::UpdateFromClientData().
|
2016-01-16 01:56:57 +00:00
|
|
|
*/
|
2016-01-16 02:06:25 +00:00
|
|
|
class WIDGET_HOTKEY_CLIENT_DATA : public wxClientData
|
2016-01-16 01:56:57 +00:00
|
|
|
{
|
2019-06-09 21:57:23 +00:00
|
|
|
HOTKEY& m_changed_hotkey;
|
2016-01-16 01:56:57 +00:00
|
|
|
|
|
|
|
public:
|
2020-12-10 22:26:35 +00:00
|
|
|
WIDGET_HOTKEY_CLIENT_DATA( HOTKEY& aChangedHotkey ) :
|
|
|
|
m_changed_hotkey( aChangedHotkey )
|
2016-01-16 02:06:25 +00:00
|
|
|
{}
|
2016-01-16 01:56:57 +00:00
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
HOTKEY& GetChangedHotkey() { return m_changed_hotkey; }
|
2016-01-16 01:56:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-01-16 01:57:10 +00:00
|
|
|
/**
|
|
|
|
* Dialog to prompt the user to enter a key.
|
|
|
|
*/
|
2016-01-16 02:06:25 +00:00
|
|
|
class HK_PROMPT_DIALOG : public DIALOG_SHIM
|
2016-01-16 01:57:10 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
HK_PROMPT_DIALOG( wxWindow* aParent, wxWindowID aId, const wxString& aTitle,
|
2020-12-10 22:26:35 +00:00
|
|
|
const wxString& aName, const wxString& aCurrentKey ) :
|
|
|
|
DIALOG_SHIM( aParent, aId, aTitle, wxDefaultPosition, wxDefaultSize )
|
2016-01-16 01:57:10 +00:00
|
|
|
{
|
|
|
|
wxPanel* panel = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize );
|
|
|
|
wxBoxSizer* sizer = new wxBoxSizer( wxVERTICAL );
|
|
|
|
|
2016-01-16 02:06:25 +00:00
|
|
|
/* Dialog layout:
|
|
|
|
*
|
|
|
|
* inst_label........................
|
|
|
|
* ----------------------------------
|
|
|
|
*
|
|
|
|
* cmd_label_0 cmd_label_1 \
|
|
|
|
* | fgsizer
|
|
|
|
* key_label_0 key_label_1 /
|
|
|
|
*/
|
2016-01-16 01:58:23 +00:00
|
|
|
|
2016-01-16 01:57:10 +00:00
|
|
|
wxStaticText* inst_label = new wxStaticText( panel, wxID_ANY, wxEmptyString,
|
2020-12-10 22:26:35 +00:00
|
|
|
wxDefaultPosition, wxDefaultSize,
|
|
|
|
wxALIGN_CENTRE_HORIZONTAL );
|
2016-01-16 02:06:25 +00:00
|
|
|
|
2016-01-16 01:58:23 +00:00
|
|
|
inst_label->SetLabelText( _( "Press a new hotkey, or press Esc to cancel..." ) );
|
|
|
|
sizer->Add( inst_label, 0, wxALL, 5 );
|
2016-01-16 01:57:10 +00:00
|
|
|
|
2016-01-16 01:58:23 +00:00
|
|
|
sizer->Add( new wxStaticLine( panel ), 0, wxALL | wxEXPAND, 2 );
|
2016-01-16 01:57:10 +00:00
|
|
|
|
2016-01-16 01:58:23 +00:00
|
|
|
wxFlexGridSizer* fgsizer = new wxFlexGridSizer( 2 );
|
|
|
|
|
|
|
|
wxStaticText* cmd_label_0 = new wxStaticText( panel, wxID_ANY, _( "Command:" ) );
|
|
|
|
fgsizer->Add( cmd_label_0, 0, wxALL | wxALIGN_CENTRE_VERTICAL, 5 );
|
|
|
|
|
2016-01-16 02:07:35 +00:00
|
|
|
wxStaticText* cmd_label_1 = new wxStaticText( panel, wxID_ANY, wxEmptyString );
|
2016-01-16 02:07:42 +00:00
|
|
|
cmd_label_1->SetFont( cmd_label_1->GetFont().Bold() );
|
2016-01-16 02:07:35 +00:00
|
|
|
cmd_label_1->SetLabel( aName );
|
2016-01-16 01:58:23 +00:00
|
|
|
fgsizer->Add( cmd_label_1, 0, wxALL | wxALIGN_CENTRE_VERTICAL, 5 );
|
|
|
|
|
|
|
|
wxStaticText* key_label_0 = new wxStaticText( panel, wxID_ANY, _( "Current key:" ) );
|
|
|
|
fgsizer->Add( key_label_0, 0, wxALL | wxALIGN_CENTRE_VERTICAL, 5 );
|
|
|
|
|
2016-01-16 02:07:35 +00:00
|
|
|
wxStaticText* key_label_1 = new wxStaticText( panel, wxID_ANY, wxEmptyString );
|
2016-01-16 02:07:42 +00:00
|
|
|
key_label_1->SetFont( key_label_1->GetFont().Bold() );
|
2016-01-16 02:07:35 +00:00
|
|
|
key_label_1->SetLabel( aCurrentKey );
|
2016-01-16 01:58:23 +00:00
|
|
|
fgsizer->Add( key_label_1, 0, wxALL | wxALIGN_CENTRE_VERTICAL, 5 );
|
2016-01-16 01:57:10 +00:00
|
|
|
|
2016-01-16 01:58:23 +00:00
|
|
|
sizer->Add( fgsizer, 1, wxEXPAND );
|
2016-01-16 01:57:10 +00:00
|
|
|
|
|
|
|
// Wrap the sizer in a second to give a larger border around the whole dialog
|
|
|
|
wxBoxSizer* outer_sizer = new wxBoxSizer( wxVERTICAL );
|
2016-01-16 01:58:23 +00:00
|
|
|
outer_sizer->Add( sizer, 0, wxALL | wxEXPAND, 10 );
|
2016-01-16 01:57:10 +00:00
|
|
|
panel->SetSizer( outer_sizer );
|
|
|
|
|
|
|
|
Layout();
|
|
|
|
outer_sizer->Fit( this );
|
|
|
|
Center();
|
|
|
|
|
|
|
|
SetMinClientSize( GetClientSize() );
|
|
|
|
|
2020-12-10 22:26:35 +00:00
|
|
|
// Binding both EVT_CHAR and EVT_CHAR_HOOK ensures that all key events, including
|
|
|
|
// specials like Tab and Return, are received, particularly on MSW.
|
2016-01-16 01:57:10 +00:00
|
|
|
panel->Bind( wxEVT_CHAR, &HK_PROMPT_DIALOG::OnChar, this );
|
2016-01-16 02:07:12 +00:00
|
|
|
panel->Bind( wxEVT_CHAR_HOOK, &HK_PROMPT_DIALOG::OnCharHook, this );
|
2021-09-20 15:59:18 +00:00
|
|
|
panel->Bind( wxEVT_KEY_UP, &HK_PROMPT_DIALOG::OnKeyUp, this );
|
2020-12-11 01:53:15 +00:00
|
|
|
SetInitialFocus( panel );
|
2016-01-16 01:57:10 +00:00
|
|
|
}
|
|
|
|
|
2020-11-11 00:18:35 +00:00
|
|
|
static wxKeyEvent PromptForKey( wxWindow* aParent, const wxString& aName,
|
2020-12-10 22:26:35 +00:00
|
|
|
const wxString& aCurrentKey )
|
2020-11-11 00:18:35 +00:00
|
|
|
{
|
|
|
|
HK_PROMPT_DIALOG dialog( aParent, wxID_ANY, _( "Set Hotkey" ), aName, aCurrentKey );
|
|
|
|
|
|
|
|
if( dialog.ShowModal() == wxID_OK )
|
|
|
|
return dialog.m_event;
|
|
|
|
else
|
|
|
|
return wxKeyEvent();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void OnCharHook( wxKeyEvent& aEvent ) override
|
2016-01-16 01:57:10 +00:00
|
|
|
{
|
2020-12-10 22:26:35 +00:00
|
|
|
// On certain platforms, EVT_CHAR_HOOK is the only handler that receives certain
|
|
|
|
// "special" keys. However, it doesn't always receive "normal" keys correctly. For
|
|
|
|
// example, with a US keyboard, it sees ? as shift+/.
|
2016-01-16 02:07:12 +00:00
|
|
|
//
|
2020-12-10 22:26:35 +00:00
|
|
|
// Untangling these incorrect keys would be too much trouble, so we bind both events,
|
|
|
|
// and simply skip the EVT_CHAR_HOOK if it receives a "normal" key.
|
2016-01-16 02:07:12 +00:00
|
|
|
|
2016-01-16 02:07:28 +00:00
|
|
|
const enum wxKeyCode skipped_keys[] =
|
|
|
|
{
|
2020-12-10 22:26:35 +00:00
|
|
|
WXK_NONE, WXK_SHIFT, WXK_ALT, WXK_CONTROL, WXK_CAPITAL, WXK_NUMLOCK, WXK_SCROLL,
|
|
|
|
WXK_RAW_CONTROL
|
2016-01-16 02:07:28 +00:00
|
|
|
};
|
2016-01-16 02:07:12 +00:00
|
|
|
|
|
|
|
int key = aEvent.GetKeyCode();
|
|
|
|
|
2019-06-14 10:55:54 +00:00
|
|
|
for( wxKeyCode skipped_key : skipped_keys )
|
2016-01-16 02:07:12 +00:00
|
|
|
{
|
2019-06-14 10:55:54 +00:00
|
|
|
if( key == skipped_key )
|
2016-01-16 02:07:12 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-01-16 02:07:19 +00:00
|
|
|
if( key <= 255 && isprint( key ) && !isspace( key ) )
|
2016-01-16 02:06:59 +00:00
|
|
|
{
|
2016-01-16 02:07:12 +00:00
|
|
|
// Let EVT_CHAR handle this one
|
|
|
|
aEvent.DoAllowNextEvent();
|
2016-01-16 02:07:28 +00:00
|
|
|
|
|
|
|
// On Windows, wxEvent::Skip must NOT be called.
|
|
|
|
// On Linux and OSX, wxEvent::Skip MUST be called.
|
|
|
|
// No, I don't know why.
|
2016-01-16 02:07:19 +00:00
|
|
|
#ifndef __WXMSW__
|
2016-01-16 02:07:12 +00:00
|
|
|
aEvent.Skip();
|
2016-01-16 02:07:19 +00:00
|
|
|
#endif
|
2016-01-16 02:06:59 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-01-16 02:07:12 +00:00
|
|
|
OnChar( aEvent );
|
|
|
|
}
|
|
|
|
}
|
2016-01-16 02:07:06 +00:00
|
|
|
|
2016-01-16 02:07:12 +00:00
|
|
|
void OnChar( wxKeyEvent& aEvent )
|
|
|
|
{
|
|
|
|
m_event = aEvent;
|
2021-09-20 15:59:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OnKeyUp( wxKeyEvent& aEvent )
|
|
|
|
{
|
2021-12-14 18:13:45 +00:00
|
|
|
// If dialog opened using Enter key, prevent closing when releasing Enter.
|
|
|
|
if( m_event.GetEventType() != wxEVT_NULL )
|
|
|
|
{
|
|
|
|
/// This needs to occur in KeyUp, so that we don't pass the event back to pcbnew
|
|
|
|
wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
|
|
|
|
}
|
2016-01-16 01:57:10 +00:00
|
|
|
}
|
2021-07-21 21:37:49 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
wxKeyEvent m_event;
|
2016-01-16 01:57:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-08-01 09:15:05 +00:00
|
|
|
/**
|
2021-07-21 21:37:49 +00:00
|
|
|
* Manage logic for filtering hotkeys based on user input.
|
2018-08-01 09:15:05 +00:00
|
|
|
*/
|
|
|
|
class HOTKEY_FILTER
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
HOTKEY_FILTER( const wxString& aFilterStr )
|
|
|
|
{
|
|
|
|
m_normalised_filter_str = aFilterStr.Upper();
|
|
|
|
m_valid = m_normalised_filter_str.size() > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-11-16 22:46:39 +00:00
|
|
|
* Check if the filter matches the given hotkey
|
2018-08-01 09:15:05 +00:00
|
|
|
*
|
|
|
|
* @return true on match (or if filter is disabled)
|
|
|
|
*/
|
2019-06-09 21:57:23 +00:00
|
|
|
bool FilterMatches( const HOTKEY& aHotkey ) const
|
2018-08-01 09:15:05 +00:00
|
|
|
{
|
|
|
|
if( !m_valid )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
// Match in the (translated) filter string
|
2023-10-27 22:40:35 +00:00
|
|
|
const auto normedInfo = wxGetTranslation( aHotkey.m_Actions[ 0 ]->GetFriendlyName() ).Upper();
|
2020-12-10 22:26:35 +00:00
|
|
|
|
2018-08-01 09:15:05 +00:00
|
|
|
if( normedInfo.Contains( m_normalised_filter_str ) )
|
|
|
|
return true;
|
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
const wxString keyName = KeyNameFromKeyCode( aHotkey.m_EditKeycode );
|
2020-12-10 22:26:35 +00:00
|
|
|
|
2018-08-01 09:15:05 +00:00
|
|
|
if( keyName.Upper().Contains( m_normalised_filter_str ) )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2020-12-10 22:26:35 +00:00
|
|
|
bool m_valid;
|
2018-08-01 09:15:05 +00:00
|
|
|
wxString m_normalised_filter_str;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-12-12 03:24:49 +00:00
|
|
|
WIDGET_HOTKEY_CLIENT_DATA* WIDGET_HOTKEY_LIST::getHKClientData( wxTreeListItem aItem )
|
2016-01-16 01:56:57 +00:00
|
|
|
{
|
|
|
|
if( aItem.IsOk() )
|
|
|
|
{
|
|
|
|
wxClientData* data = GetItemData( aItem );
|
2016-01-16 02:06:25 +00:00
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
if( data )
|
2016-01-16 01:56:57 +00:00
|
|
|
return static_cast<WIDGET_HOTKEY_CLIENT_DATA*>( data );
|
|
|
|
}
|
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
return nullptr;
|
2016-01-16 01:56:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-09-27 13:44:03 +00:00
|
|
|
WIDGET_HOTKEY_CLIENT_DATA* WIDGET_HOTKEY_LIST::getExpectedHkClientData( wxTreeListItem aItem )
|
|
|
|
{
|
2020-12-12 03:24:49 +00:00
|
|
|
const auto hkdata = getHKClientData( aItem );
|
2018-09-27 13:44:03 +00:00
|
|
|
|
|
|
|
// This probably means a hotkey-only action is being attempted on
|
|
|
|
// a row that is not a hotkey (like a section heading)
|
|
|
|
wxASSERT_MSG( hkdata != nullptr, "No hotkey data found for list item" );
|
|
|
|
|
|
|
|
return hkdata;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-12 03:24:49 +00:00
|
|
|
void WIDGET_HOTKEY_LIST::updateFromClientData()
|
2016-01-16 01:56:57 +00:00
|
|
|
{
|
|
|
|
for( wxTreeListItem i = GetFirstItem(); i.IsOk(); i = GetNextItem( i ) )
|
|
|
|
{
|
2020-12-12 03:24:49 +00:00
|
|
|
WIDGET_HOTKEY_CLIENT_DATA* hkdata = getHKClientData( i );
|
2016-01-16 01:56:57 +00:00
|
|
|
|
|
|
|
if( hkdata )
|
|
|
|
{
|
2020-09-04 15:20:51 +00:00
|
|
|
const HOTKEY& changed_hk = hkdata->GetChangedHotkey();
|
2023-10-27 22:40:35 +00:00
|
|
|
wxString label = changed_hk.m_Actions[ 0 ]->GetFriendlyName();
|
2020-09-04 15:20:51 +00:00
|
|
|
wxString key_text = KeyNameFromKeyCode( changed_hk.m_EditKeycode );
|
2023-07-13 14:08:00 +00:00
|
|
|
wxString alt_text = KeyNameFromKeyCode( changed_hk.m_EditKeycodeAlt );
|
2023-06-29 23:06:03 +00:00
|
|
|
wxString description = changed_hk.m_Actions[ 0 ]->GetDescription();
|
2018-09-27 11:30:43 +00:00
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
if( label.IsEmpty() )
|
2019-06-14 10:55:54 +00:00
|
|
|
label = changed_hk.m_Actions[ 0 ]->GetName();
|
2019-07-16 16:29:50 +00:00
|
|
|
|
2022-07-26 22:38:40 +00:00
|
|
|
label.Replace( wxT( "..." ), wxEmptyString );
|
2022-07-26 23:12:54 +00:00
|
|
|
label.Replace( wxT( "…" ), wxEmptyString );
|
2022-07-26 22:38:40 +00:00
|
|
|
|
2018-09-27 11:30:43 +00:00
|
|
|
// mark unsaved changes
|
2019-06-14 10:55:54 +00:00
|
|
|
if( changed_hk.m_EditKeycode != changed_hk.m_Actions[ 0 ]->GetHotKey() )
|
2023-01-17 04:14:38 +00:00
|
|
|
label += wxS( " *" );
|
2016-01-16 01:56:57 +00:00
|
|
|
|
2022-07-26 22:38:40 +00:00
|
|
|
description.Replace( wxS( "\n" ), wxS( " " ) );
|
|
|
|
description.Replace( wxS( "\r" ), wxS( " " ) );
|
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
SetItemText( i, 0, label );
|
2023-07-13 14:08:00 +00:00
|
|
|
SetItemText( i, 1, key_text );
|
|
|
|
SetItemText( i, 2, alt_text );
|
|
|
|
SetItemText( i, 3, description );
|
2016-01-16 01:56:57 +00:00
|
|
|
}
|
|
|
|
}
|
2018-09-27 12:31:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-07-13 14:08:00 +00:00
|
|
|
void WIDGET_HOTKEY_LIST::changeHotkey( HOTKEY& aHotkey, long aKey, bool alternate )
|
2018-09-27 12:31:24 +00:00
|
|
|
{
|
|
|
|
// See if this key code is handled in hotkeys names list
|
|
|
|
bool exists;
|
|
|
|
KeyNameFromKeyCode( aKey, &exists );
|
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
if( exists && aHotkey.m_EditKeycode != aKey )
|
2018-09-27 12:31:24 +00:00
|
|
|
{
|
2020-12-12 03:24:49 +00:00
|
|
|
if( aKey == 0 || resolveKeyConflicts( aHotkey.m_Actions[ 0 ], aKey ) )
|
2023-07-13 14:08:00 +00:00
|
|
|
{
|
|
|
|
if( alternate )
|
|
|
|
aHotkey.m_EditKeycodeAlt = aKey;
|
|
|
|
else
|
|
|
|
aHotkey.m_EditKeycode = aKey;
|
|
|
|
}
|
2018-09-27 12:31:24 +00:00
|
|
|
}
|
2016-01-16 01:56:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-07-13 14:08:00 +00:00
|
|
|
void WIDGET_HOTKEY_LIST::editItem( wxTreeListItem aItem, int aEditId )
|
2016-01-16 01:56:57 +00:00
|
|
|
{
|
2018-09-27 13:44:03 +00:00
|
|
|
WIDGET_HOTKEY_CLIENT_DATA* hkdata = getExpectedHkClientData( aItem );
|
2016-01-16 01:57:10 +00:00
|
|
|
|
|
|
|
if( !hkdata )
|
|
|
|
return;
|
|
|
|
|
2016-01-16 02:06:25 +00:00
|
|
|
wxString name = GetItemText( aItem, 0 );
|
2023-07-13 14:08:00 +00:00
|
|
|
wxString current_key =
|
|
|
|
aEditId == ID_EDIT_HOTKEY ? GetItemText( aItem, 1 ) : GetItemText( aItem, 2 );
|
2016-01-16 01:57:10 +00:00
|
|
|
|
2021-09-20 15:59:18 +00:00
|
|
|
wxKeyEvent key_event = HK_PROMPT_DIALOG::PromptForKey( this, name, current_key );
|
2016-01-16 02:06:07 +00:00
|
|
|
long key = MapKeypressToKeycode( key_event );
|
2016-01-16 01:56:57 +00:00
|
|
|
|
2018-09-27 13:44:03 +00:00
|
|
|
if( key )
|
2016-01-16 01:56:57 +00:00
|
|
|
{
|
2021-09-20 15:59:18 +00:00
|
|
|
auto it = m_reservedHotkeys.find( key );
|
|
|
|
|
|
|
|
if( it != m_reservedHotkeys.end() )
|
|
|
|
{
|
2023-04-16 21:49:54 +00:00
|
|
|
wxString msg = wxString::Format( _( "'%s' is a reserved hotkey in KiCad and cannot "
|
|
|
|
"be assigned." ),
|
|
|
|
it->second );
|
2021-09-20 15:59:18 +00:00
|
|
|
|
|
|
|
DisplayErrorMessage( this, msg );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-07-13 14:08:00 +00:00
|
|
|
changeHotkey( hkdata->GetChangedHotkey(), key, aEditId == ID_EDIT_ALT );
|
2020-12-12 03:24:49 +00:00
|
|
|
updateFromClientData();
|
2016-01-16 01:56:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-12 03:24:49 +00:00
|
|
|
void WIDGET_HOTKEY_LIST::resetItem( wxTreeListItem aItem, int aResetId )
|
2016-01-16 01:58:53 +00:00
|
|
|
{
|
2018-09-27 13:44:03 +00:00
|
|
|
WIDGET_HOTKEY_CLIENT_DATA* hkdata = getExpectedHkClientData( aItem );
|
|
|
|
|
|
|
|
if( !hkdata )
|
|
|
|
return;
|
2016-01-16 01:58:53 +00:00
|
|
|
|
2020-09-04 15:20:51 +00:00
|
|
|
HOTKEY& changed_hk = hkdata->GetChangedHotkey();
|
2018-09-27 12:31:24 +00:00
|
|
|
|
2019-06-14 10:55:54 +00:00
|
|
|
if( aResetId == ID_RESET )
|
2023-07-13 14:08:00 +00:00
|
|
|
{
|
|
|
|
changeHotkey( changed_hk, changed_hk.m_Actions[0]->GetHotKey(), false );
|
|
|
|
changeHotkey( changed_hk, changed_hk.m_Actions[0]->GetHotKey(), true );
|
|
|
|
}
|
2019-06-14 10:55:54 +00:00
|
|
|
else if( aResetId == ID_CLEAR )
|
2023-07-13 14:08:00 +00:00
|
|
|
changeHotkey( changed_hk, 0, false );
|
|
|
|
else if( aResetId == ID_CLEAR_ALT )
|
|
|
|
changeHotkey( changed_hk, 0, true );
|
2019-06-14 10:55:54 +00:00
|
|
|
else if( aResetId == ID_DEFAULT )
|
2023-07-13 14:08:00 +00:00
|
|
|
{
|
|
|
|
changeHotkey( changed_hk, changed_hk.m_Actions[0]->GetDefaultHotKey(), false );
|
|
|
|
changeHotkey( changed_hk, changed_hk.m_Actions[0]->GetDefaultHotKeyAlt(), true );
|
|
|
|
}
|
2016-01-16 01:58:53 +00:00
|
|
|
|
2020-12-12 03:24:49 +00:00
|
|
|
updateFromClientData();
|
2016-03-30 18:51:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-12 03:24:49 +00:00
|
|
|
void WIDGET_HOTKEY_LIST::onActivated( wxTreeListEvent& aEvent )
|
2016-01-16 01:58:53 +00:00
|
|
|
{
|
2023-07-13 14:08:00 +00:00
|
|
|
editItem( aEvent.GetItem(), ID_EDIT_HOTKEY );
|
2016-01-16 01:58:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-12 03:24:49 +00:00
|
|
|
void WIDGET_HOTKEY_LIST::onContextMenu( wxTreeListEvent& aEvent )
|
2016-01-16 01:58:53 +00:00
|
|
|
{
|
|
|
|
// Save the active event for use in OnMenu
|
|
|
|
m_context_menu_item = aEvent.GetItem();
|
|
|
|
|
|
|
|
wxMenu menu;
|
|
|
|
|
2020-12-12 03:24:49 +00:00
|
|
|
WIDGET_HOTKEY_CLIENT_DATA* hkdata = getHKClientData( m_context_menu_item );
|
2018-09-27 13:44:03 +00:00
|
|
|
|
|
|
|
// Some actions only apply if the row is hotkey data
|
|
|
|
if( hkdata )
|
|
|
|
{
|
2019-05-26 15:36:40 +00:00
|
|
|
menu.Append( ID_EDIT_HOTKEY, _( "Edit..." ) );
|
2023-07-13 14:08:00 +00:00
|
|
|
menu.Append( ID_EDIT_ALT, _( "Edit Alternate..." ) );
|
2018-09-27 13:44:03 +00:00
|
|
|
menu.Append( ID_RESET, _( "Undo Changes" ) );
|
2019-06-14 10:55:54 +00:00
|
|
|
menu.Append( ID_CLEAR, _( "Clear Assigned Hotkey" ) );
|
2023-07-13 14:08:00 +00:00
|
|
|
menu.Append( ID_CLEAR_ALT, _( "Clear Assigned Alternate" ) );
|
|
|
|
menu.Append( ID_DEFAULT, _( "Restore Defaults" ) );
|
2018-09-27 13:44:03 +00:00
|
|
|
menu.Append( wxID_SEPARATOR );
|
|
|
|
|
2019-06-14 10:55:54 +00:00
|
|
|
PopupMenu( &menu );
|
|
|
|
}
|
2016-01-16 01:58:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-12 03:24:49 +00:00
|
|
|
void WIDGET_HOTKEY_LIST::onMenu( wxCommandEvent& aEvent )
|
2016-01-16 01:58:53 +00:00
|
|
|
{
|
|
|
|
switch( aEvent.GetId() )
|
|
|
|
{
|
2023-04-16 21:49:54 +00:00
|
|
|
case ID_EDIT_HOTKEY:
|
2023-07-13 14:08:00 +00:00
|
|
|
case ID_EDIT_ALT:
|
|
|
|
editItem( m_context_menu_item, aEvent.GetId() );
|
2016-01-16 01:58:53 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ID_RESET:
|
2019-06-14 10:55:54 +00:00
|
|
|
case ID_CLEAR:
|
2023-07-13 14:08:00 +00:00
|
|
|
case ID_CLEAR_ALT:
|
2023-04-16 21:49:54 +00:00
|
|
|
case ID_DEFAULT:
|
2023-07-13 14:08:00 +00:00
|
|
|
resetItem( m_context_menu_item, aEvent.GetId() );
|
2016-03-30 18:51:47 +00:00
|
|
|
break;
|
|
|
|
|
2016-01-16 01:58:53 +00:00
|
|
|
default:
|
|
|
|
wxFAIL_MSG( wxT( "Unknown ID in context menu event" ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-12 03:24:49 +00:00
|
|
|
bool WIDGET_HOTKEY_LIST::resolveKeyConflicts( TOOL_ACTION* aAction, long aKey )
|
2016-01-16 01:56:57 +00:00
|
|
|
{
|
2019-06-09 21:57:23 +00:00
|
|
|
HOTKEY* conflictingHotKey = nullptr;
|
2016-01-16 01:56:57 +00:00
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
m_hk_store.CheckKeyConflicts( aAction, aKey, &conflictingHotKey );
|
2016-01-16 01:56:57 +00:00
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
if( !conflictingHotKey )
|
|
|
|
return true;
|
2019-07-16 16:29:50 +00:00
|
|
|
|
2019-06-14 10:55:54 +00:00
|
|
|
TOOL_ACTION* conflictingAction = conflictingHotKey->m_Actions[ 0 ];
|
2021-06-28 23:44:07 +00:00
|
|
|
wxString msg = wxString::Format( _( "'%s' is already assigned to '%s' in section '%s'. "
|
2019-06-09 21:57:23 +00:00
|
|
|
"Are you sure you want to change its assignment?" ),
|
|
|
|
KeyNameFromKeyCode( aKey ),
|
2023-10-27 22:40:35 +00:00
|
|
|
conflictingAction->GetFriendlyName(),
|
2019-06-09 21:57:23 +00:00
|
|
|
HOTKEY_STORE::GetSectionName( conflictingAction ) );
|
2016-01-16 01:56:57 +00:00
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
wxMessageDialog dlg( GetParent(), msg, _( "Confirm change" ), wxYES_NO | wxNO_DEFAULT );
|
2016-01-16 01:56:57 +00:00
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
if( dlg.ShowModal() == wxID_YES )
|
2016-01-16 01:56:57 +00:00
|
|
|
{
|
2019-06-09 21:57:23 +00:00
|
|
|
// Reset the other hotkey
|
|
|
|
conflictingHotKey->m_EditKeycode = 0;
|
2020-12-12 03:24:49 +00:00
|
|
|
updateFromClientData();
|
2016-01-16 01:56:57 +00:00
|
|
|
return true;
|
|
|
|
}
|
2019-06-09 21:57:23 +00:00
|
|
|
|
|
|
|
return false;
|
2016-01-16 01:56:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-10-02 21:37:15 +00:00
|
|
|
WIDGET_HOTKEY_LIST::WIDGET_HOTKEY_LIST( wxWindow* aParent, HOTKEY_STORE& aHotkeyStore,
|
2020-12-10 22:26:35 +00:00
|
|
|
bool aReadOnly ) :
|
|
|
|
wxTreeListCtrl( aParent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTL_SINGLE ),
|
2018-10-02 21:37:15 +00:00
|
|
|
m_hk_store( aHotkeyStore ),
|
2020-09-04 15:20:51 +00:00
|
|
|
m_readOnly( aReadOnly )
|
2016-01-16 01:56:57 +00:00
|
|
|
{
|
2018-10-02 21:37:15 +00:00
|
|
|
wxString command_header = _( "Command" );
|
|
|
|
|
|
|
|
if( !m_readOnly )
|
2023-01-17 04:14:38 +00:00
|
|
|
command_header << wxS( " " ) << _( "(double-click to edit)" );
|
2018-10-02 21:37:15 +00:00
|
|
|
|
2020-12-05 01:10:28 +00:00
|
|
|
AppendColumn( command_header, 450, wxALIGN_LEFT, wxCOL_RESIZABLE | wxCOL_SORTABLE );
|
|
|
|
AppendColumn( _( "Hotkey" ), 120, wxALIGN_LEFT, wxCOL_RESIZABLE | wxCOL_SORTABLE );
|
2023-07-13 14:08:00 +00:00
|
|
|
AppendColumn( _( "Alternate" ), 120, wxALIGN_LEFT, wxCOL_RESIZABLE | wxCOL_SORTABLE );
|
2020-12-05 01:10:28 +00:00
|
|
|
AppendColumn( _( "Description" ), 900, wxALIGN_LEFT, wxCOL_RESIZABLE | wxCOL_SORTABLE );
|
2020-12-17 01:51:18 +00:00
|
|
|
|
|
|
|
|
2021-01-10 11:52:57 +00:00
|
|
|
#if defined( __WXGTK__ )// && !wxCHECK_VERSION( 3, 1, 0 )
|
2020-12-17 01:51:18 +00:00
|
|
|
// Automatic column widths are broken in wxGTK 3.0.x; set min widths to ensure visibility
|
2021-01-10 11:52:57 +00:00
|
|
|
// They are also broken in wxGTK 3.1.4
|
2020-12-17 01:51:18 +00:00
|
|
|
|
|
|
|
wxDataViewCtrl* dv = GetDataView();
|
|
|
|
|
|
|
|
wxString longKey = wxT( "Ctrl+Alt+Shift+X" );
|
|
|
|
int pad = 20;
|
|
|
|
|
2022-07-26 22:38:40 +00:00
|
|
|
dv->GetColumn( 0 )->SetMinWidth( aParent->GetTextExtent( command_header ).x * 2 + pad );
|
|
|
|
dv->GetColumn( 1 )->SetMinWidth( aParent->GetTextExtent( longKey ).x + pad );
|
2023-07-13 14:08:00 +00:00
|
|
|
dv->GetColumn( 2 )->SetMinWidth( aParent->GetTextExtent( longKey ).x + pad );
|
|
|
|
dv->GetColumn( 3 )->SetMinWidth( aParent->GetTextExtent( command_header ).x * 5 + pad );
|
2021-12-13 23:37:36 +00:00
|
|
|
|
|
|
|
CallAfter( [&]()
|
|
|
|
{
|
|
|
|
GetDataView()->Update();
|
|
|
|
} );
|
2022-07-26 22:38:40 +00:00
|
|
|
#endif
|
2020-12-17 01:51:18 +00:00
|
|
|
|
2021-09-20 15:59:18 +00:00
|
|
|
std::vector<wxString> reserved_keys =
|
2023-04-16 21:49:54 +00:00
|
|
|
{
|
|
|
|
wxS( "Ctrl+Tab" ),
|
|
|
|
wxS( "Ctrl+Shift+Tab" )
|
|
|
|
};
|
2021-09-20 15:59:18 +00:00
|
|
|
|
2022-07-26 22:38:40 +00:00
|
|
|
for( const wxString& key : reserved_keys )
|
2021-09-20 15:59:18 +00:00
|
|
|
{
|
|
|
|
long code = KeyCodeFromKeyName( key );
|
|
|
|
|
|
|
|
if( code )
|
|
|
|
m_reservedHotkeys[code] = key;
|
|
|
|
else
|
2023-01-17 04:14:38 +00:00
|
|
|
wxLogWarning( wxS( "Unknown reserved keycode %s\n" ), key );
|
2021-09-20 15:59:18 +00:00
|
|
|
}
|
|
|
|
|
2020-03-26 16:06:37 +00:00
|
|
|
GetDataView()->SetIndent( 10 );
|
2016-01-16 01:56:57 +00:00
|
|
|
|
2018-10-02 21:37:15 +00:00
|
|
|
if( !m_readOnly )
|
|
|
|
{
|
|
|
|
// The event only apply if the widget is in editable mode
|
2020-12-12 03:24:49 +00:00
|
|
|
Bind( wxEVT_TREELIST_ITEM_ACTIVATED, &WIDGET_HOTKEY_LIST::onActivated, this );
|
|
|
|
Bind( wxEVT_TREELIST_ITEM_CONTEXT_MENU, &WIDGET_HOTKEY_LIST::onContextMenu, this );
|
|
|
|
Bind( wxEVT_MENU, &WIDGET_HOTKEY_LIST::onMenu, this );
|
2018-10-02 21:37:15 +00:00
|
|
|
}
|
2016-01-16 01:56:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-08-01 09:15:05 +00:00
|
|
|
void WIDGET_HOTKEY_LIST::ApplyFilterString( const wxString& aFilterStr )
|
|
|
|
{
|
|
|
|
updateShownItems( aFilterStr );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-09-26 14:26:26 +00:00
|
|
|
void WIDGET_HOTKEY_LIST::ResetAllHotkeys( bool aResetToDefault )
|
2016-03-29 16:35:24 +00:00
|
|
|
{
|
|
|
|
Freeze();
|
|
|
|
|
2018-09-26 14:26:26 +00:00
|
|
|
// Reset all the hotkeys, not just the ones shown
|
|
|
|
// Should not need to check conflicts, as the state we're about
|
|
|
|
// to set to a should be consistent
|
|
|
|
if( aResetToDefault )
|
|
|
|
m_hk_store.ResetAllHotkeysToDefault();
|
|
|
|
else
|
|
|
|
m_hk_store.ResetAllHotkeysToOriginal();
|
2016-03-29 16:35:24 +00:00
|
|
|
|
2020-12-12 03:24:49 +00:00
|
|
|
updateFromClientData();
|
2020-12-17 01:51:18 +00:00
|
|
|
updateColumnWidths();
|
2020-12-11 01:53:15 +00:00
|
|
|
|
2016-03-29 16:35:24 +00:00
|
|
|
Thaw();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-08-01 09:15:05 +00:00
|
|
|
bool WIDGET_HOTKEY_LIST::TransferDataToControl()
|
|
|
|
{
|
|
|
|
updateShownItems( "" );
|
2020-12-17 01:51:18 +00:00
|
|
|
updateColumnWidths();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2020-12-11 01:53:15 +00:00
|
|
|
|
2020-12-17 01:51:18 +00:00
|
|
|
|
|
|
|
void WIDGET_HOTKEY_LIST::updateColumnWidths()
|
|
|
|
{
|
2020-12-11 01:53:15 +00:00
|
|
|
wxDataViewColumn* col = GetDataView()->GetColumn( 0 );
|
|
|
|
col->SetWidth( wxCOL_WIDTH_AUTOSIZE );
|
|
|
|
col->SetWidth( col->GetWidth() );
|
|
|
|
|
|
|
|
col = GetDataView()->GetColumn( 1 );
|
|
|
|
col->SetWidth( wxCOL_WIDTH_AUTOSIZE );
|
|
|
|
col->SetWidth( col->GetWidth() );
|
|
|
|
|
2022-07-26 22:38:40 +00:00
|
|
|
col = GetDataView()->GetColumn( 2 );
|
|
|
|
col->SetWidth( wxCOL_WIDTH_AUTOSIZE );
|
|
|
|
col->SetWidth( col->GetWidth() );
|
|
|
|
|
2023-07-13 14:08:00 +00:00
|
|
|
col = GetDataView()->GetColumn( 3 );
|
|
|
|
col->SetWidth( wxCOL_WIDTH_AUTOSIZE );
|
|
|
|
col->SetWidth( col->GetWidth() );
|
2018-08-01 09:15:05 +00:00
|
|
|
}
|
2018-09-26 14:26:26 +00:00
|
|
|
|
|
|
|
|
2018-08-01 09:15:05 +00:00
|
|
|
void WIDGET_HOTKEY_LIST::updateShownItems( const wxString& aFilterStr )
|
2016-01-16 01:56:57 +00:00
|
|
|
{
|
|
|
|
Freeze();
|
|
|
|
DeleteAllItems();
|
|
|
|
|
2018-08-01 09:15:05 +00:00
|
|
|
HOTKEY_FILTER filter( aFilterStr );
|
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
for( HOTKEY_SECTION& section: m_hk_store.GetSections() )
|
2016-01-16 01:56:57 +00:00
|
|
|
{
|
|
|
|
// Create parent tree item
|
2019-06-09 21:57:23 +00:00
|
|
|
wxTreeListItem parent = AppendItem( GetRootItem(), section.m_SectionName );
|
2016-01-16 02:06:25 +00:00
|
|
|
|
2019-06-09 21:57:23 +00:00
|
|
|
for( HOTKEY& hotkey: section.m_HotKeys )
|
2016-01-16 01:56:57 +00:00
|
|
|
{
|
2019-06-09 21:57:23 +00:00
|
|
|
if( filter.FilterMatches( hotkey ) )
|
2018-08-01 09:15:05 +00:00
|
|
|
{
|
|
|
|
wxTreeListItem item = AppendItem( parent, wxEmptyString );
|
|
|
|
SetItemData( item, new WIDGET_HOTKEY_CLIENT_DATA( hotkey ) );
|
|
|
|
}
|
2016-01-16 01:56:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Expand( parent );
|
|
|
|
}
|
|
|
|
|
2020-12-12 03:24:49 +00:00
|
|
|
updateFromClientData();
|
2016-01-16 01:56:57 +00:00
|
|
|
Thaw();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool WIDGET_HOTKEY_LIST::TransferDataFromControl()
|
|
|
|
{
|
2018-09-26 14:26:26 +00:00
|
|
|
m_hk_store.SaveAllHotkeys();
|
2016-01-16 01:56:57 +00:00
|
|
|
return true;
|
|
|
|
}
|
2016-01-16 01:58:31 +00:00
|
|
|
|
2016-01-16 02:06:25 +00:00
|
|
|
|
2016-01-16 01:58:31 +00:00
|
|
|
long WIDGET_HOTKEY_LIST::MapKeypressToKeycode( const wxKeyEvent& aEvent )
|
|
|
|
{
|
|
|
|
long key = aEvent.GetKeyCode();
|
2021-09-20 15:59:18 +00:00
|
|
|
bool is_tab = aEvent.IsKeyInCategory( WXK_CATEGORY_TAB );
|
2016-01-16 01:58:31 +00:00
|
|
|
|
|
|
|
if( key == WXK_ESCAPE )
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-01-16 02:06:25 +00:00
|
|
|
if( key >= 'a' && key <= 'z' ) // convert to uppercase
|
2016-01-16 01:58:31 +00:00
|
|
|
key = key + ('A' - 'a');
|
|
|
|
|
|
|
|
// Remap Ctrl A (=1+GR_KB_CTRL) to Ctrl Z(=26+GR_KB_CTRL)
|
|
|
|
// to GR_KB_CTRL+'A' .. GR_KB_CTRL+'Z'
|
2021-09-20 15:59:18 +00:00
|
|
|
if( !is_tab && aEvent.ControlDown() && key >= WXK_CONTROL_A && key <= WXK_CONTROL_Z )
|
2016-01-16 01:58:31 +00:00
|
|
|
key += 'A' - 1;
|
|
|
|
|
|
|
|
/* Disallow shift for keys that have two keycodes on them (e.g. number and
|
2021-09-06 19:16:35 +00:00
|
|
|
* punctuation keys) leaving only the "letter keys" of A-Z, tab and space
|
2016-01-16 02:06:25 +00:00
|
|
|
* Then, you can have, e.g. Ctrl-5 and Ctrl-% (GB layout)
|
|
|
|
* and Ctrl-( and Ctrl-5 (FR layout).
|
|
|
|
* Otherwise, you'd have to have to say Ctrl-Shift-5 on a FR layout
|
|
|
|
*/
|
2016-01-16 01:58:31 +00:00
|
|
|
bool keyIsLetter = key >= 'A' && key <= 'Z';
|
|
|
|
|
2021-09-06 19:16:35 +00:00
|
|
|
if( aEvent.ShiftDown() && ( keyIsLetter || key > 256 || key == 9 || key == 32 ) )
|
2019-06-12 08:57:39 +00:00
|
|
|
key |= MD_SHIFT;
|
2016-01-16 01:58:31 +00:00
|
|
|
|
|
|
|
if( aEvent.ControlDown() )
|
2019-06-12 08:57:39 +00:00
|
|
|
key |= MD_CTRL;
|
2016-01-16 01:58:31 +00:00
|
|
|
|
|
|
|
if( aEvent.AltDown() )
|
2019-06-12 08:57:39 +00:00
|
|
|
key |= MD_ALT;
|
2016-01-16 01:58:31 +00:00
|
|
|
|
|
|
|
return key;
|
|
|
|
}
|
|
|
|
}
|