Changeset 454 for trunk


Ignore:
Timestamp:
Jun 1, 2010, 9:55:30 PM (11 years ago)
Author:
dmik
Message:

Fixed: The main menu is not navigable with the keyboard (closes ticket:203).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Lucide/gui/lucide.cpp

    r452 r454  
    12451245}
    12461246
     1247static bool isAncestorOf( HWND hwnd1, HWND hwnd2 )
     1248{
     1249    static HWND desktop = NULLHANDLE;
     1250    if ( desktop == NULLHANDLE )
     1251        desktop = WinQueryDesktopWindow( hab, NULLHANDLE );
     1252
     1253    if ( hwnd1 == NULLHANDLE || hwnd2 == NULLHANDLE )
     1254        return false;
     1255
     1256    while ( hwnd2 != hwnd1 && hwnd2 != desktop )
     1257        hwnd2 = WinQueryWindow( hwnd2, QW_PARENT );
     1258
     1259    return hwnd2 == hwnd1;
     1260}
     1261
    12471262static MRESULT EXPENTRY frameProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 )
    12481263{
     
    12531268            // change the accel logic by first letting the focus window process
    12541269            // WM_CHAR and only translate it to accel if not handled (this makes
    1255             // sure that keyboard shortcuts in input fields work even if we
    1256             // defined our own accelerators from these shortcuts). Make an
    1257             // exception for VK_TAB since it's always eaten by the standard
    1258             // window procedure and therefore the accel table will never be
    1259             // called
     1270            // sure that standard keyboard shortcuts in e.g. input fields work
     1271            // even if we define our own accelerators from these shortcuts in
     1272            // the main window). Make an exception for VK_TAB since it's always
     1273            // eaten by the standard window procedure and therefore the accel
     1274            // table will never be called. Note that we do this trick only for
     1275            // the document window and its children: other windows such as the
     1276            // standard frame controls like menu etc. are known to demonstrate
     1277            // weird behavior (for example, the menu window seems to exit the
     1278            // menu mode on any WM_CHAR sent to it)
     1279            HWND focus = WinQueryFocus( HWND_DESKTOP );
     1280            if ( !isAncestorOf( docViewer->getFrameHWND(), focus ) )
     1281                break;
    12601282            PQMSG pqmsg = (PQMSG)mp1;
     1283            if ( pqmsg->msg != WM_CHAR )
     1284                break;
    12611285            if ( !( SHORT1FROMMP( pqmsg->mp1 ) & KC_VIRTUALKEY ) ||
    12621286                 !( SHORT2FROMMP( pqmsg->mp2 ) == VK_TAB ) )
    12631287            {
    1264                 HWND focus = WinQueryFocus( HWND_DESKTOP );
    12651288                if ( focus == pqmsg->hwnd && focus != hwnd ) {
    12661289                    if ( WinDispatchMsg( hab, pqmsg ) ) {
Note: See TracChangeset for help on using the changeset viewer.