mirror of
https://github.com/Open-Shell/Open-Shell-Menu.git
synced 2026-04-11 17:37:22 +10:00
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:
@@ -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();
|
||||
|
||||
@@ -808,7 +808,7 @@ private:
|
||||
void ActivateItem( int index, TActivateType type, const POINT *pPt, ActivateData *pData=NULL );
|
||||
void ActivateTreeItem( const void *treeItem, RECT &itemRect, TActivateType type, const POINT *pPt, ActivateData *pData=NULL );
|
||||
void DragTreeItem( const void *treeItem, bool bApps );
|
||||
void ShowKeyboardCues( void );
|
||||
void ShowKeyboardCues( bool alt );
|
||||
void SetActiveWindow( void );
|
||||
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
|
||||
void BlendPatterns( unsigned int *bits, int width, int height );
|
||||
|
||||
@@ -4361,6 +4361,7 @@ CSetting g_Settings[]={
|
||||
{L"BoldSettings",CSetting::TYPE_BOOL,IDS_BOLD_SETTINGS,IDS_BOLD_SETTINGS_TIP,1},
|
||||
{L"ReportSkinErrors",CSetting::TYPE_BOOL,IDS_SKIN_ERRORS,IDS_SKIN_ERRORS_TIP,0},
|
||||
{L"EnableAccelerators",CSetting::TYPE_BOOL,IDS_ENABLE_ACCELERATORS,IDS_ENABLE_ACCELERATORS_TIP,1},
|
||||
{L"AltAccelerators",CSetting::TYPE_BOOL,IDS_ALT_ACCELERATORS,IDS_ALT_ACCELERATORS_TIP,0,0,L"EnableAccelerators",L"EnableAccelerators"},
|
||||
|
||||
{L"SearchBoxSettings",CSetting::TYPE_GROUP,IDS_SEARCH_BOX},
|
||||
{L"SearchBox",CSetting::TYPE_INT,IDS_SHOW_SEARCH_BOX,IDS_SHOW_SEARCH_BOX_TIP,SEARCHBOX_TAB,CSetting::FLAG_BASIC},
|
||||
|
||||
@@ -639,6 +639,8 @@ BEGIN
|
||||
IDS_PIC_COMMAND "User picture command"
|
||||
IDS_ENABLE_ACCELERATORS "Enable accelerators"
|
||||
IDS_ENABLE_ACCELERATORS_TIP "Use keyboard accelerators to execute menu commands"
|
||||
IDS_ALT_ACCELERATORS "Require Alt key for accelerators"
|
||||
IDS_ALT_ACCELERATORS_TIP "Keyboard accelerators will be triggered only if Alt key is pressed"
|
||||
END
|
||||
|
||||
STRINGTABLE
|
||||
|
||||
@@ -782,6 +782,8 @@
|
||||
#define IDS_PINNED_PATH_TIP 3685
|
||||
#define IDS_ENABLE_ACCELERATORS 3686
|
||||
#define IDS_ENABLE_ACCELERATORS_TIP 3687
|
||||
#define IDS_ALT_ACCELERATORS 3688
|
||||
#define IDS_ALT_ACCELERATORS_TIP 3689
|
||||
#define IDS_STRING7001 7001
|
||||
#define IDS_STRING7002 7002
|
||||
#define IDS_STRING7003 7003
|
||||
|
||||
Reference in New Issue
Block a user