Skip to content

Commit 23a1dc7

Browse files
committed
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
1 parent a7b6a80 commit 23a1dc7

File tree

5 files changed

+17
-6
lines changed

5 files changed

+17
-6
lines changed

Src/StartMenu/StartMenuDLL/MenuContainer.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ LRESULT CALLBACK CMenuContainer::SubclassSearchBox( HWND hWnd, UINT uMsg, WPARAM
569569
{
570570
pParent->SendMessage(WM_SYSKEYDOWN,wParam,lParam);
571571
if (wParam==VK_MENU)
572-
pParent->ShowKeyboardCues();
572+
pParent->ShowKeyboardCues(true);
573573
}
574574
else
575575
{
@@ -5113,11 +5113,14 @@ void CMenuContainer::UpdateSearchResults( bool bForceShowAll )
51135113
}
51145114

51155115
// Turn on the keyboard cues from now on. This is done when a keyboard action is detected
5116-
void CMenuContainer::ShowKeyboardCues( void )
5116+
void CMenuContainer::ShowKeyboardCues( bool alt )
51175117
{
51185118
if (!GetSettingBool(L"EnableAccelerators"))
51195119
return;
51205120

5121+
if (GetSettingBool(L"AltAccelerators") && !alt)
5122+
return;
5123+
51215124
if (!s_bKeyboardCues)
51225125
{
51235126
s_bKeyboardCues=true;
@@ -5149,7 +5152,7 @@ LRESULT CMenuContainer::OnSysCommand( UINT uMsg, WPARAM wParam, LPARAM lParam, B
51495152
if ((wParam&0xFFF0)==SC_KEYMENU)
51505153
{
51515154
// stops Alt from activating the window menu
5152-
ShowKeyboardCues();
5155+
ShowKeyboardCues(true);
51535156
s_bOverrideFirstDown=false;
51545157
}
51555158
else
@@ -5492,7 +5495,7 @@ bool CMenuContainer::CanSelectItem( int index, bool bKeyboard )
54925495

54935496
LRESULT CMenuContainer::OnKeyDown( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled )
54945497
{
5495-
ShowKeyboardCues();
5498+
ShowKeyboardCues((HIWORD(lParam)&KF_ALTDOWN)!=0);
54965499
bool bOldOverride=s_bOverrideFirstDown;
54975500
s_bOverrideFirstDown=false;
54985501

@@ -6115,6 +6118,9 @@ LRESULT CMenuContainer::OnChar( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& b
61156118
if (!GetSettingBool(L"EnableAccelerators"))
61166119
return TRUE;
61176120

6121+
if (GetSettingBool(L"AltAccelerators") && !(HIWORD(lParam) & KF_ALTDOWN))
6122+
return TRUE;
6123+
61186124
if (wParam>=0xD800 && wParam<=0xDBFF)
61196125
return TRUE; // don't support supplementary characters
61206126

@@ -8076,7 +8082,7 @@ HWND CMenuContainer::ToggleStartMenu( int taskbarId, bool bKeyboard, bool bAllPr
80768082

80778083
s_bNoDragDrop=!GetSettingBool(L"EnableDragDrop");
80788084
s_bNoContextMenu=!GetSettingBool(L"EnableContextMenu");
8079-
s_bKeyboardCues=bKeyboard&&GetSettingBool(L"EnableAccelerators");
8085+
s_bKeyboardCues=bKeyboard&&GetSettingBool(L"EnableAccelerators")&&!GetSettingBool(L"AltAccelerators");
80808086
s_RecentPrograms=(TRecentPrograms)GetSettingInt(L"RecentPrograms");
80818087
if (s_RecentPrograms!=RECENT_PROGRAMS_NONE)
80828088
LoadMRUShortcuts();

Src/StartMenu/StartMenuDLL/MenuContainer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,7 @@ class CMenuContainer: public IDropTarget, public IFrameworkInputPaneHandler, pub
808808
void ActivateItem( int index, TActivateType type, const POINT *pPt, ActivateData *pData=NULL );
809809
void ActivateTreeItem( const void *treeItem, RECT &itemRect, TActivateType type, const POINT *pPt, ActivateData *pData=NULL );
810810
void DragTreeItem( const void *treeItem, bool bApps );
811-
void ShowKeyboardCues( void );
811+
void ShowKeyboardCues( bool alt );
812812
void SetActiveWindow( void );
813813
void CreateBackground( int width1, int width2, int height1, int height2, int &totalWidth, int &totalHeight, bool bCreateRegion ); // width1/2, height1/2 - the first and second content area
814814
void BlendPatterns( unsigned int *bits, int width, int height );

Src/StartMenu/StartMenuDLL/SettingsUI.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4361,6 +4361,7 @@ CSetting g_Settings[]={
43614361
{L"BoldSettings",CSetting::TYPE_BOOL,IDS_BOLD_SETTINGS,IDS_BOLD_SETTINGS_TIP,1},
43624362
{L"ReportSkinErrors",CSetting::TYPE_BOOL,IDS_SKIN_ERRORS,IDS_SKIN_ERRORS_TIP,0},
43634363
{L"EnableAccelerators",CSetting::TYPE_BOOL,IDS_ENABLE_ACCELERATORS,IDS_ENABLE_ACCELERATORS_TIP,1},
4364+
{L"AltAccelerators",CSetting::TYPE_BOOL,IDS_ALT_ACCELERATORS,IDS_ALT_ACCELERATORS_TIP,0,0,L"EnableAccelerators",L"EnableAccelerators"},
43644365

43654366
{L"SearchBoxSettings",CSetting::TYPE_GROUP,IDS_SEARCH_BOX},
43664367
{L"SearchBox",CSetting::TYPE_INT,IDS_SHOW_SEARCH_BOX,IDS_SHOW_SEARCH_BOX_TIP,SEARCHBOX_TAB,CSetting::FLAG_BASIC},

Src/StartMenu/StartMenuDLL/StartMenuDLL.rc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,8 @@ BEGIN
639639
IDS_PIC_COMMAND "User picture command"
640640
IDS_ENABLE_ACCELERATORS "Enable accelerators"
641641
IDS_ENABLE_ACCELERATORS_TIP "Use keyboard accelerators to execute menu commands"
642+
IDS_ALT_ACCELERATORS "Require Alt key for accelerators"
643+
IDS_ALT_ACCELERATORS_TIP "Keyboard accelerators will be triggered only if Alt key is pressed"
642644
END
643645

644646
STRINGTABLE

Src/StartMenu/StartMenuDLL/resource.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,8 @@
782782
#define IDS_PINNED_PATH_TIP 3685
783783
#define IDS_ENABLE_ACCELERATORS 3686
784784
#define IDS_ENABLE_ACCELERATORS_TIP 3687
785+
#define IDS_ALT_ACCELERATORS 3688
786+
#define IDS_ALT_ACCELERATORS_TIP 3689
785787
#define IDS_STRING7001 7001
786788
#define IDS_STRING7002 7002
787789
#define IDS_STRING7003 7003

0 commit comments

Comments
 (0)