From 1e531c31600a76e1d55e2f2e5abd351ff80bc4fd Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Mon, 13 Sep 2021 17:29:27 +0100 Subject: tdf#142415 mouse events not propogated to table control event handlers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit handle this with explicit callbacks from the cell widget for those events Change-Id: Ie605ca4286afc0fbd321f339fb7963771a303df5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122050 Tested-by: Jenkins Reviewed-by: Caolán McNamara --- svx/source/fmcomp/gridcell.cxx | 68 +++++++++++++++++++++++------------------- svx/source/inc/gridcell.hxx | 4 +++ 2 files changed, 42 insertions(+), 30 deletions(-) (limited to 'svx') diff --git a/svx/source/fmcomp/gridcell.cxx b/svx/source/fmcomp/gridcell.cxx index f5eb27fbf2b8..c0cb0d1e376c 100644 --- a/svx/source/fmcomp/gridcell.cxx +++ b/svx/source/fmcomp/gridcell.cxx @@ -3103,6 +3103,9 @@ void FmXGridCell::init() pEventWindow->AddEventListener( LINK( this, FmXGridCell, OnWindowEvent ) ); pEventWindow->SetFocusInHdl(LINK( this, FmXGridCell, OnFocusGained)); pEventWindow->SetFocusOutHdl(LINK( this, FmXGridCell, OnFocusLost)); + pEventWindow->SetMousePressHdl(LINK( this, FmXGridCell, OnMousePress)); + pEventWindow->SetMouseReleaseHdl(LINK( this, FmXGridCell, OnMouseRelease)); + pEventWindow->SetMouseMoveHdl(LINK( this, FmXGridCell, OnMouseMove)); } } @@ -3376,45 +3379,50 @@ IMPL_LINK_NOARG(FmXGridCell, OnFocusLost, LinkParamNone*, void) onFocusLost(aEvent); } -void FmXGridCell::onWindowEvent(const VclEventId _nEventId, const void* _pEventData) +IMPL_LINK(FmXGridCell, OnMousePress, const MouseEvent&, rEventData, void) { - switch ( _nEventId ) - { - case VclEventId::WindowMouseButtonDown: - case VclEventId::WindowMouseButtonUp: - { - if ( !m_aMouseListeners.getLength() ) - break; + if (!m_aMouseListeners.getLength()) + return; + + awt::MouseEvent aEvent(VCLUnoHelper::createMouseEvent(rEventData, *this)); + m_aMouseListeners.notifyEach(&awt::XMouseListener::mousePressed, aEvent); +} - const bool bButtonDown = ( _nEventId == VclEventId::WindowMouseButtonDown ); +IMPL_LINK(FmXGridCell, OnMouseRelease, const MouseEvent&, rEventData, void) +{ + if (!m_aMouseListeners.getLength()) + return; - awt::MouseEvent aEvent( VCLUnoHelper::createMouseEvent( *static_cast< const ::MouseEvent* >( _pEventData ), *this ) ); - m_aMouseListeners.notifyEach( bButtonDown ? &awt::XMouseListener::mousePressed : &awt::XMouseListener::mouseReleased, aEvent ); - } - break; - case VclEventId::WindowMouseMove: + awt::MouseEvent aEvent(VCLUnoHelper::createMouseEvent(rEventData, *this)); + m_aMouseListeners.notifyEach(&awt::XMouseListener::mouseReleased, aEvent); +} + +IMPL_LINK(FmXGridCell, OnMouseMove, const MouseEvent&, rMouseEvent, void) +{ + if ( rMouseEvent.IsEnterWindow() || rMouseEvent.IsLeaveWindow() ) { - const MouseEvent& rMouseEvent = *static_cast< const ::MouseEvent* >( _pEventData ); - if ( rMouseEvent.IsEnterWindow() || rMouseEvent.IsLeaveWindow() ) + if ( m_aMouseListeners.getLength() != 0 ) { - if ( m_aMouseListeners.getLength() != 0 ) - { - awt::MouseEvent aEvent( VCLUnoHelper::createMouseEvent( rMouseEvent, *this ) ); - m_aMouseListeners.notifyEach( rMouseEvent.IsEnterWindow() ? &awt::XMouseListener::mouseEntered: &awt::XMouseListener::mouseExited, aEvent ); - } + awt::MouseEvent aEvent( VCLUnoHelper::createMouseEvent( rMouseEvent, *this ) ); + m_aMouseListeners.notifyEach( rMouseEvent.IsEnterWindow() ? &awt::XMouseListener::mouseEntered: &awt::XMouseListener::mouseExited, aEvent ); } - else if ( !rMouseEvent.IsEnterWindow() && !rMouseEvent.IsLeaveWindow() ) + } + else if ( !rMouseEvent.IsEnterWindow() && !rMouseEvent.IsLeaveWindow() ) + { + if ( m_aMouseMotionListeners.getLength() != 0 ) { - if ( m_aMouseMotionListeners.getLength() != 0 ) - { - awt::MouseEvent aEvent( VCLUnoHelper::createMouseEvent( rMouseEvent, *this ) ); - aEvent.ClickCount = 0; - const bool bSimpleMove = bool( rMouseEvent.GetMode() & MouseEventModifiers::SIMPLEMOVE ); - m_aMouseMotionListeners.notifyEach( bSimpleMove ? &awt::XMouseMotionListener::mouseMoved: &awt::XMouseMotionListener::mouseDragged, aEvent ); - } + awt::MouseEvent aEvent( VCLUnoHelper::createMouseEvent( rMouseEvent, *this ) ); + aEvent.ClickCount = 0; + const bool bSimpleMove = bool( rMouseEvent.GetMode() & MouseEventModifiers::SIMPLEMOVE ); + m_aMouseMotionListeners.notifyEach( bSimpleMove ? &awt::XMouseMotionListener::mouseMoved: &awt::XMouseMotionListener::mouseDragged, aEvent ); } } - break; +} + +void FmXGridCell::onWindowEvent(const VclEventId _nEventId, const void* _pEventData) +{ + switch ( _nEventId ) + { case VclEventId::WindowKeyInput: case VclEventId::WindowKeyUp: { diff --git a/svx/source/inc/gridcell.hxx b/svx/source/inc/gridcell.hxx index 306dc5764ca1..be5161d1a2b3 100644 --- a/svx/source/inc/gridcell.hxx +++ b/svx/source/inc/gridcell.hxx @@ -782,6 +782,10 @@ private: svt::ControlBase* getEventWindow() const; DECL_LINK(OnFocusGained, LinkParamNone*, void); DECL_LINK(OnFocusLost, LinkParamNone*, void); + DECL_LINK(OnMousePress, const MouseEvent&, void); + DECL_LINK(OnMouseRelease, const MouseEvent&, void); + DECL_LINK(OnMouseMove, const MouseEvent&, void); + DECL_LINK( OnWindowEvent, VclWindowEvent&, void ); }; -- cgit