diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-06-15 12:17:10 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-06-15 18:05:46 +0200 |
commit | d6533cb372bd75f839674fd36640fa466d496efd (patch) | |
tree | 912dde5cfdd6fbafb1a47baac9de8c790ac96178 /sc | |
parent | ac18631b850c9d1d7b7348fdd56823526bcc1bfe (diff) |
ReleaseMouse so focus can be grabbed by the FilterFloat
otherwise the keyboard events don't get to the dropdown
Change-Id: I6cbaea5e3cef16a39edb12fecdf1d08ab29cbd5c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96366
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/ui/inc/gridwin.hxx | 4 | ||||
-rw-r--r-- | sc/source/ui/view/gridwin.cxx | 32 |
2 files changed, 25 insertions, 11 deletions
diff --git a/sc/source/ui/inc/gridwin.hxx b/sc/source/ui/inc/gridwin.hxx index b3439381f702..9dfedd12ade8 100644 --- a/sc/source/ui/inc/gridwin.hxx +++ b/sc/source/ui/inc/gridwin.hxx @@ -82,6 +82,8 @@ struct SpellCallbackInfo; // predefines namespace sdr::overlay { class OverlayObjectList; } +class ScFilterFloatingWindow; + class SAL_DLLPUBLIC_RTTI ScGridWindow : public vcl::Window, public DropTargetHelper, public DragSourceHelper { // ScFilterListBox is always used for selection list @@ -152,7 +154,7 @@ class SAL_DLLPUBLIC_RTTI ScGridWindow : public vcl::Window, public DropTargetHel std::unique_ptr<ScNoteMarker, o3tl::default_delete<ScNoteMarker>> mpNoteMarker; VclPtr<ScFilterListBox> mpFilterBox; - VclPtr<FloatingWindow> mpFilterFloat; + VclPtr<ScFilterFloatingWindow> mpFilterFloat; VclPtr<ScCheckListMenuWindow> mpAutoFilterPopup; VclPtr<ScCheckListMenuWindow> mpDPFieldPopup; std::unique_ptr<ScDPFieldButton> mpFilterButton; diff --git a/sc/source/ui/view/gridwin.cxx b/sc/source/ui/view/gridwin.cxx index 1cda62bba554..1f49e48a68c4 100644 --- a/sc/source/ui/view/gridwin.cxx +++ b/sc/source/ui/view/gridwin.cxx @@ -311,21 +311,25 @@ IMPL_LINK_NOARG(ScFilterListBox, AsyncSelectHdl, void*, void) pGridWin->ClickExtern(); } -namespace { - // use a System floating window for the above filter listbox class ScFilterFloatingWindow : public FloatingWindow { +private: + bool m_bGridHadMouseCaptured; public: ScFilterFloatingWindow(vcl::Window* pParent); virtual ~ScFilterFloatingWindow() override; virtual void dispose() override; -}; -} + bool MouseWasCaptured() const + { + return m_bGridHadMouseCaptured; + } +}; ScFilterFloatingWindow::ScFilterFloatingWindow(vcl::Window* pParent) : FloatingWindow( pParent, WB_BORDER | WB_SYSTEMWINDOW ) // make it a system floater + , m_bGridHadMouseCaptured(pParent->IsMouseCaptured()) { } @@ -540,6 +544,10 @@ IMPL_LINK_NOARG(ScGridWindow, PopupModeEndHdl, FloatingWindow*, void) { if (mpFilterBox) mpFilterBox->SetCancelled(); // cancel select + // restore the mouse capture state of the GridWindow to + // what it was at initial popup time + if (mpFilterFloat->MouseWasCaptured()) + CaptureMouse(); GrabFocus(); } @@ -980,6 +988,9 @@ void ScGridWindow::ShowFilterMenu(const tools::Rectangle& rCellRect, bool bLayou mpFilterBox->SetSizePixel(aSize); mpFilterFloat->SetOutputSizePixel(aSize); + + if (IsMouseCaptured()) + ReleaseMouse(); mpFilterFloat->StartPopupMode(aCellRect, FloatWinPopupFlags::Down|FloatWinPopupFlags::GrabFocus); } @@ -1070,11 +1081,6 @@ void ScGridWindow::DoScenarioMenu( const ScRange& rScenRange ) rFilterBox.select(nPos); } mpFilterBox->EndInit(); - - // Scenario selection comes from MouseButtonDown: - // The next MouseMove on the FilterBox is like a ButtonDown - nMouseStatus = SC_GM_FILTER; - CaptureMouse(); } void ScGridWindow::LaunchDataSelectMenu( SCCOL nCol, SCROW nRow ) @@ -1771,7 +1777,6 @@ void ScGridWindow::HandleMouseButtonDown( const MouseEvent& rMEvt, MouseEventSta LaunchDataSelectMenu( aListValPos.Col(), aListValPos.Row() ); nMouseStatus = SC_GM_FILTER; // not set in DoAutoFilterMenue for bDataSelect - CaptureMouse(); rState.mbActivatePart = false; return; } @@ -1783,7 +1788,14 @@ void ScGridWindow::HandleMouseButtonDown( const MouseEvent& rMEvt, MouseEventSta ScRange aScenRange; if ( rMEvt.IsLeft() && HasScenarioButton( aPos, aScenRange ) ) { + CaptureMouse(); + DoScenarioMenu( aScenRange ); + + // Scenario selection comes from MouseButtonDown: + // The next MouseMove on the FilterBox is like a ButtonDown + nMouseStatus = SC_GM_FILTER; + return; } |