diff options
author | Caolán McNamara <caolanm@redhat.com> | 2016-07-11 13:01:52 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2016-07-11 13:25:15 +0100 |
commit | 545d5157f26b7fd3c5648ae6e727b1e1addca68f (patch) | |
tree | 247694e633cdc735d058cbf79f20cfe5b4839eac /vcl | |
parent | 89a5464a21046821648ec77f03db8316ceb4e6f8 (diff) |
Resolves: tdf#95729 move 'alt' accel enable/disable down to systemwindow
from dialog and send the 'alt' to the active floating window, if there
is one, before trying the menubar.
so popups like the calc autofilter one can display their accelerators
when alt is pressed
Change-Id: I52e45b72885b1b0a7362cecc30e41d218a48a58d
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/window/dialog.cxx | 48 | ||||
-rw-r--r-- | vcl/source/window/syswin.cxx | 51 | ||||
-rw-r--r-- | vcl/source/window/winproc.cxx | 17 |
3 files changed, 62 insertions, 54 deletions
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx index 9a872bd2db55..63657f5c1557 100644 --- a/vcl/source/window/dialog.cxx +++ b/vcl/source/window/dialog.cxx @@ -240,16 +240,6 @@ void ImplWindowAutoMnemonic( vcl::Window* pWindow ) } } -void ImplHandleControlAccelerator( vcl::Window* pWindow, bool bShow ) -{ - Control *pControl = dynamic_cast<Control*>(pWindow->ImplGetWindow()); - if (pControl && pControl->GetText().indexOf('~') != -1) - { - pControl->SetShowAccelerator( bShow ); - pControl->Invalidate(InvalidateFlags::Update); - } -} - static VclButtonBox* getActionArea(Dialog *pDialog) { VclButtonBox *pButtonBox = nullptr; @@ -597,39 +587,6 @@ IMPL_LINK_NOARG_TYPED(Dialog, ImplAsyncCloseHdl, void*, void) Close(); } -bool Dialog::ImplHandleCmdEvent( const CommandEvent& rCEvent ) -{ - if (rCEvent.GetCommand() == CommandEventId::ModKeyChange) - { - const CommandModKeyData *pCData = rCEvent.GetModKeyData (); - bool bShowAccel = pCData && pCData->IsMod2(); - - Window *pGetChild = firstLogicalChildOfParent(this); - while (pGetChild) - { - if ( pGetChild->GetType() == WINDOW_TABCONTROL ) - { - // find currently shown tab page - TabControl* pTabControl = static_cast<TabControl*>( pGetChild ); - TabPage* pTabPage = pTabControl->GetTabPage( pTabControl->GetCurPageId() ); - vcl::Window* pTabPageChild = firstLogicalChildOfParent( pTabPage ); - - // and go through its children - while ( pTabPageChild ) - { - ImplHandleControlAccelerator(pTabPageChild, bShowAccel); - pTabPageChild = nextLogicalChildOfParent(pTabPage, pTabPageChild); - } - } - - ImplHandleControlAccelerator( pGetChild, bShowAccel ); - pGetChild = nextLogicalChildOfParent(this, pGetChild); - } - return true; - } - return false; -} - bool Dialog::Notify( NotifyEvent& rNEvt ) { // first call the base class due to Tab control @@ -672,11 +629,6 @@ bool Dialog::Notify( NotifyEvent& rNEvt ) } } - else if (rNEvt.GetType() == MouseNotifyEvent::COMMAND) - { - if (ImplHandleCmdEvent( *rNEvt.GetCommandEvent())) - return true; - } } return bRet; diff --git a/vcl/source/window/syswin.cxx b/vcl/source/window/syswin.cxx index 242b98a1826c..8e8e5fbf4c01 100644 --- a/vcl/source/window/syswin.cxx +++ b/vcl/source/window/syswin.cxx @@ -31,6 +31,9 @@ #include <vcl/syswin.hxx> #include <vcl/taskpanelist.hxx> #include <vcl/unowrap.hxx> +#include <vcl/tabctrl.hxx> +#include <vcl/tabpage.hxx> +#include <vcl/mnemonic.hxx> #include <rtl/strbuf.hxx> @@ -116,6 +119,49 @@ void SystemWindow::dispose() Window::dispose(); } +void ImplHandleControlAccelerator( vcl::Window* pWindow, bool bShow ) +{ + Control *pControl = dynamic_cast<Control*>(pWindow->ImplGetWindow()); + if (pControl && pControl->GetText().indexOf('~') != -1) + { + pControl->SetShowAccelerator( bShow ); + pControl->Invalidate(InvalidateFlags::Update); + } +} + +bool SystemWindow::ImplHandleCmdEvent( const CommandEvent& rCEvent ) +{ + if (rCEvent.GetCommand() == CommandEventId::ModKeyChange) + { + const CommandModKeyData *pCData = rCEvent.GetModKeyData (); + bool bShowAccel = pCData && pCData->IsMod2(); + + Window *pGetChild = firstLogicalChildOfParent(this); + while (pGetChild) + { + if ( pGetChild->GetType() == WINDOW_TABCONTROL ) + { + // find currently shown tab page + TabControl* pTabControl = static_cast<TabControl*>( pGetChild ); + TabPage* pTabPage = pTabControl->GetTabPage( pTabControl->GetCurPageId() ); + vcl::Window* pTabPageChild = firstLogicalChildOfParent( pTabPage ); + + // and go through its children + while ( pTabPageChild ) + { + ImplHandleControlAccelerator(pTabPageChild, bShowAccel); + pTabPageChild = nextLogicalChildOfParent(pTabPage, pTabPageChild); + } + } + + ImplHandleControlAccelerator( pGetChild, bShowAccel ); + pGetChild = nextLogicalChildOfParent(this, pGetChild); + } + return true; + } + return false; +} + bool SystemWindow::Notify( NotifyEvent& rNEvt ) { // capture KeyEvents for menu handling @@ -139,6 +185,11 @@ bool SystemWindow::Notify( NotifyEvent& rNEvt ) } if (bDone) return true; + if (rNEvt.GetType() == MouseNotifyEvent::COMMAND) + { + if (ImplHandleCmdEvent( *rNEvt.GetCommandEvent())) + return true; + } } return Window::Notify( rNEvt ); diff --git a/vcl/source/window/winproc.cxx b/vcl/source/window/winproc.cxx index f3da016429a7..720ee3a705e3 100644 --- a/vcl/source/window/winproc.cxx +++ b/vcl/source/window/winproc.cxx @@ -2091,14 +2091,19 @@ static void ImplHandleSalKeyMod( vcl::Window* pWindow, SalKeyModEvent* pEvent ) // Alt pressed or released => give SystemWindow a chance to handle auto-accelerator if ( pEvent->mnCode == KEY_MOD2 || (pEvent->mnModKeyCode & MODKEY_MOD2) != 0 ) { - // find window - first look to see if the system window is available - pChild = pWindow->ImplGetWindowImpl()->mpFirstChild; + // find window - first look to see a popup is open and send it there + pChild = pSVData->maWinData.mpFirstFloat.get(); - while ( pChild ) + if (!pChild) { - if ( pChild->ImplGetWindowImpl()->mbSysWin ) - break; - pChild = pChild->ImplGetWindowImpl()->mpNext; + // find window - then look to see if the system window is available + pChild = pWindow->ImplGetWindowImpl()->mpFirstChild; + while ( pChild ) + { + if ( pChild->ImplGetWindowImpl()->mbSysWin ) + break; + pChild = pChild->ImplGetWindowImpl()->mpNext; + } } } |