diff options
author | Caolán McNamara <caolanm@redhat.com> | 2021-09-13 17:29:27 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2021-09-13 22:19:36 +0200 |
commit | 1e531c31600a76e1d55e2f2e5abd351ff80bc4fd (patch) | |
tree | 88dd05ca3e40503ead4d14e395d5db42ece1a0b0 /svx/source/fmcomp | |
parent | a7084f156a75ab363d2562b485b240bd350563fc (diff) |
tdf#142415 mouse events not propogated to table control event handlers
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 <caolanm@redhat.com>
Diffstat (limited to 'svx/source/fmcomp')
-rw-r--r-- | svx/source/fmcomp/gridcell.cxx | 68 |
1 files changed, 38 insertions, 30 deletions
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: { |