Make Alt+[national key] menu shortcuts work.

This commit is contained in:
Dmitry Timoshkov 2003-11-26 05:08:48 +00:00 committed by Alexandre Julliard
parent 358fff8142
commit 86e4079bc2
4 changed files with 25 additions and 13 deletions

View file

@ -664,7 +664,7 @@ static MENUITEM *MENU_FindItemByCoords( POPUPMENU *menu,
* Return item id, -1 if none, -2 if we should close the menu. * Return item id, -1 if none, -2 if we should close the menu.
*/ */
static UINT MENU_FindItemByKey( HWND hwndOwner, HMENU hmenu, static UINT MENU_FindItemByKey( HWND hwndOwner, HMENU hmenu,
UINT key, BOOL forceMenuChar ) WCHAR key, BOOL forceMenuChar )
{ {
TRACE("\tlooking for '%c' (0x%02x) in [%p]\n", (char)key, key, hmenu ); TRACE("\tlooking for '%c' (0x%02x) in [%p]\n", (char)key, key, hmenu );
@ -3000,12 +3000,14 @@ void MENU_TrackMouseMenuBar( HWND hWnd, INT ht, POINT pt )
* *
* Menu-bar tracking upon a keyboard event. Called from NC_HandleSysCommand(). * Menu-bar tracking upon a keyboard event. Called from NC_HandleSysCommand().
*/ */
void MENU_TrackKbdMenuBar( HWND hwnd, UINT wParam, INT vkey) void MENU_TrackKbdMenuBar( HWND hwnd, UINT wParam, WCHAR wChar)
{ {
UINT uItem = NO_SELECTED_ITEM; UINT uItem = NO_SELECTED_ITEM;
HMENU hTrackMenu; HMENU hTrackMenu;
UINT wFlags = TPM_ENTERIDLEEX | TPM_LEFTALIGN | TPM_LEFTBUTTON; UINT wFlags = TPM_ENTERIDLEEX | TPM_LEFTALIGN | TPM_LEFTBUTTON;
TRACE("hwnd %p wParam 0x%04x wChar 0x%04x\n", hwnd, wParam, wChar);
/* find window that has a menu */ /* find window that has a menu */
while (GetWindowLongW( hwnd, GWL_STYLE ) & WS_CHILD) while (GetWindowLongW( hwnd, GWL_STYLE ) & WS_CHILD)
@ -3014,7 +3016,7 @@ void MENU_TrackKbdMenuBar( HWND hwnd, UINT wParam, INT vkey)
/* check if we have to track a system menu */ /* check if we have to track a system menu */
hTrackMenu = GetMenu( hwnd ); hTrackMenu = GetMenu( hwnd );
if (!hTrackMenu || IsIconic(hwnd) || vkey == VK_SPACE ) if (!hTrackMenu || IsIconic(hwnd) || wChar == ' ' )
{ {
if (!(GetWindowLongW( hwnd, GWL_STYLE ) & WS_SYSMENU)) return; if (!(GetWindowLongW( hwnd, GWL_STYLE ) & WS_SYSMENU)) return;
if (GetWindowLongW( hwnd, GWL_EXSTYLE ) & WS_EX_MANAGED) return; if (GetWindowLongW( hwnd, GWL_EXSTYLE ) & WS_EX_MANAGED) return;
@ -3027,9 +3029,9 @@ void MENU_TrackKbdMenuBar( HWND hwnd, UINT wParam, INT vkey)
MENU_InitTracking( hwnd, hTrackMenu, FALSE, wFlags ); MENU_InitTracking( hwnd, hTrackMenu, FALSE, wFlags );
if( vkey && vkey != VK_SPACE ) if( wChar && wChar != ' ' )
{ {
uItem = MENU_FindItemByKey( hwnd, hTrackMenu, vkey, (wParam & HTSYSMENU) ); uItem = MENU_FindItemByKey( hwnd, hTrackMenu, wChar, (wParam & HTSYSMENU) );
if( uItem >= (UINT)(-2) ) if( uItem >= (UINT)(-2) )
{ {
if( uItem == (UINT)(-1) ) MessageBeep(0); if( uItem == (UINT)(-1) ) MessageBeep(0);
@ -3043,7 +3045,7 @@ void MENU_TrackKbdMenuBar( HWND hwnd, UINT wParam, INT vkey)
if( uItem == NO_SELECTED_ITEM ) if( uItem == NO_SELECTED_ITEM )
MENU_MoveSelection( hwnd, hTrackMenu, ITEM_NEXT ); MENU_MoveSelection( hwnd, hTrackMenu, ITEM_NEXT );
else if( vkey ) else if( wChar )
PostMessageW( hwnd, WM_KEYDOWN, VK_DOWN, 0L ); PostMessageW( hwnd, WM_KEYDOWN, VK_DOWN, 0L );
MENU_TrackMenu( hTrackMenu, wFlags, 0, 0, hwnd, NULL ); MENU_TrackMenu( hTrackMenu, wFlags, 0, 0, hwnd, NULL );

View file

@ -59,7 +59,7 @@ extern HMENU MENU_GetSysMenu(HWND hWndOwner, HMENU hSysPopup);
extern UINT MENU_GetMenuBarHeight( HWND hwnd, UINT menubarWidth, extern UINT MENU_GetMenuBarHeight( HWND hwnd, UINT menubarWidth,
INT orgX, INT orgY ); INT orgX, INT orgY );
extern void MENU_TrackMouseMenuBar( HWND hwnd, INT ht, POINT pt ); extern void MENU_TrackMouseMenuBar( HWND hwnd, INT ht, POINT pt );
extern void MENU_TrackKbdMenuBar( HWND hwnd, UINT wParam, INT vkey ); extern void MENU_TrackKbdMenuBar( HWND hwnd, UINT wParam, WCHAR wChar );
extern UINT MENU_DrawMenuBar( HDC hDC, LPRECT lprect, extern UINT MENU_DrawMenuBar( HDC hDC, LPRECT lprect,
HWND hwnd, BOOL suppress_draw ); HWND hwnd, BOOL suppress_draw );
extern UINT MENU_FindSubMenu( HMENU *hmenu, HMENU hSubTarget ); extern UINT MENU_FindSubMenu( HMENU *hmenu, HMENU hSubTarget );

View file

@ -559,7 +559,7 @@ static LRESULT DEFWND_DefWinProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPa
iF10Key = 1; iF10Key = 1;
else else
if( wParam == VK_ESCAPE && (GetKeyState(VK_SHIFT) & 0x8000)) if( wParam == VK_ESCAPE && (GetKeyState(VK_SHIFT) & 0x8000))
SendMessageW( hwnd, WM_SYSCOMMAND, SC_KEYMENU, VK_SPACE ); SendMessageW( hwnd, WM_SYSCOMMAND, SC_KEYMENU, ' ' );
break; break;
case WM_KEYUP: case WM_KEYUP:
@ -572,23 +572,25 @@ static LRESULT DEFWND_DefWinProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPa
break; break;
case WM_SYSCHAR: case WM_SYSCHAR:
{
iMenuSysKey = 0; iMenuSysKey = 0;
if (wParam == VK_RETURN && IsIconic(hwnd)) if (wParam == '\r' && IsIconic(hwnd))
{ {
PostMessageW( hwnd, WM_SYSCOMMAND, SC_RESTORE, 0L ); PostMessageW( hwnd, WM_SYSCOMMAND, SC_RESTORE, 0L );
break; break;
} }
if ((HIWORD(lParam) & KEYDATA_ALT) && wParam) if ((HIWORD(lParam) & KEYDATA_ALT) && wParam)
{ {
if (wParam == VK_TAB || wParam == VK_ESCAPE) break; if (wParam == '\t' || wParam == '\x1b') break;
if (wParam == VK_SPACE && (GetWindowLongW( hwnd, GWL_STYLE ) & WS_CHILD)) if (wParam == ' ' && (GetWindowLongW( hwnd, GWL_STYLE ) & WS_CHILD))
SendMessageW( GetParent(hwnd), msg, wParam, lParam ); SendMessageW( GetParent(hwnd), msg, wParam, lParam );
else else
SendMessageW( hwnd, WM_SYSCOMMAND, SC_KEYMENU, wParam ); SendMessageW( hwnd, WM_SYSCOMMAND, SC_KEYMENU, wParam );
} }
else /* check for Ctrl-Esc */ else /* check for Ctrl-Esc */
if (wParam != VK_ESCAPE) MessageBeep(0); if (wParam != '\x1b') MessageBeep(0);
break; break;
}
case WM_SHOWWINDOW: case WM_SHOWWINDOW:
{ {
@ -867,6 +869,14 @@ LRESULT WINAPI DefWindowProcA( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam
result = 0; result = 0;
break; break;
case WM_SYSCHAR:
{
BYTE ch = LOWORD(wParam);
WCHAR wch;
MultiByteToWideChar(CP_ACP, 0, &ch, 1, &wch, 1);
wParam = MAKEWPARAM( wch, HIWORD(wParam) );
}
/* fall through */
default: default:
result = DEFWND_DefWinProc( hwnd, msg, wParam, lParam ); result = DEFWND_DefWinProc( hwnd, msg, wParam, lParam );
break; break;

View file

@ -2193,7 +2193,7 @@ LONG NC_HandleSysCommand( HWND hwnd, WPARAM wParam, LPARAM lParam )
break; break;
case SC_KEYMENU: case SC_KEYMENU:
MENU_TrackKbdMenuBar( hwnd, wParam, LOWORD(lParam) ); MENU_TrackKbdMenuBar( hwnd, wParam, (WCHAR)lParam );
break; break;
case SC_TASKLIST: case SC_TASKLIST: