Added new option "Require Alt key for accelerators"

With the option enabled keyboard accelerators will be triggered only if Alt key
is pressed as well.

This is how typical Windows keyboard accelerators work, to avoid
confusion with regular key presses.

Fixes #117
This commit is contained in:
ge0rdi
2022-12-19 14:30:59 +01:00
parent a7b6a80799
commit 23a1dc7e07
5 changed files with 17 additions and 6 deletions

View File

@@ -569,7 +569,7 @@ LRESULT CALLBACK CMenuContainer::SubclassSearchBox( HWND hWnd, UINT uMsg, WPARAM
{
pParent->SendMessage(WM_SYSKEYDOWN,wParam,lParam);
if (wParam==VK_MENU)
pParent->ShowKeyboardCues();
pParent->ShowKeyboardCues(true);
}
else
{
@@ -5113,11 +5113,14 @@ void CMenuContainer::UpdateSearchResults( bool bForceShowAll )
}
// Turn on the keyboard cues from now on. This is done when a keyboard action is detected
void CMenuContainer::ShowKeyboardCues( void )
void CMenuContainer::ShowKeyboardCues( bool alt )
{
if (!GetSettingBool(L"EnableAccelerators"))
return;
if (GetSettingBool(L"AltAccelerators") && !alt)
return;
if (!s_bKeyboardCues)
{
s_bKeyboardCues=true;
@@ -5149,7 +5152,7 @@ LRESULT CMenuContainer::OnSysCommand( UINT uMsg, WPARAM wParam, LPARAM lParam, B
if ((wParam&0xFFF0)==SC_KEYMENU)
{
// stops Alt from activating the window menu
ShowKeyboardCues();
ShowKeyboardCues(true);
s_bOverrideFirstDown=false;
}
else
@@ -5492,7 +5495,7 @@ bool CMenuContainer::CanSelectItem( int index, bool bKeyboard )
LRESULT CMenuContainer::OnKeyDown( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled )
{
ShowKeyboardCues();
ShowKeyboardCues((HIWORD(lParam)&KF_ALTDOWN)!=0);
bool bOldOverride=s_bOverrideFirstDown;
s_bOverrideFirstDown=false;
@@ -6115,6 +6118,9 @@ LRESULT CMenuContainer::OnChar( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& b
if (!GetSettingBool(L"EnableAccelerators"))
return TRUE;
if (GetSettingBool(L"AltAccelerators") && !(HIWORD(lParam) & KF_ALTDOWN))
return TRUE;
if (wParam>=0xD800 && wParam<=0xDBFF)
return TRUE; // don't support supplementary characters
@@ -8076,7 +8082,7 @@ HWND CMenuContainer::ToggleStartMenu( int taskbarId, bool bKeyboard, bool bAllPr
s_bNoDragDrop=!GetSettingBool(L"EnableDragDrop");
s_bNoContextMenu=!GetSettingBool(L"EnableContextMenu");
s_bKeyboardCues=bKeyboard&&GetSettingBool(L"EnableAccelerators");
s_bKeyboardCues=bKeyboard&&GetSettingBool(L"EnableAccelerators")&&!GetSettingBool(L"AltAccelerators");
s_RecentPrograms=(TRecentPrograms)GetSettingInt(L"RecentPrograms");
if (s_RecentPrograms!=RECENT_PROGRAMS_NONE)
LoadMRUShortcuts();