diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-12-19 11:55:05 +0000 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-12-20 08:50:46 +0000 |
commit | 7a770a8fb7628288aaaee868331c01f39afb5b71 (patch) | |
tree | 01c04cb3a82f8f773c14115f48d11bd6d5f57980 /svx | |
parent | 9d846a1d77a1ba157c55589a6b2ccb6388eef35d (diff) |
Resolves: tdf#146933 wire up keypress events for table control widgets
Change-Id: Idc8cc3c24d061537a76a37f4fa84951a41a42657
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144546
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/fmcomp/gridcell.cxx | 40 | ||||
-rw-r--r-- | svx/source/inc/gridcell.hxx | 6 |
2 files changed, 17 insertions, 29 deletions
diff --git a/svx/source/fmcomp/gridcell.cxx b/svx/source/fmcomp/gridcell.cxx index 74c14d42dbd1..67e5d00403b0 100644 --- a/svx/source/fmcomp/gridcell.cxx +++ b/svx/source/fmcomp/gridcell.cxx @@ -3204,12 +3204,13 @@ void FmXGridCell::init() svt::ControlBase* pEventWindow( getEventWindow() ); if ( pEventWindow ) { - 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)); + pEventWindow->SetKeyInputHdl( LINK( this, FmXGridCell, OnKeyInput) ); + pEventWindow->SetKeyReleaseHdl( LINK( this, FmXGridCell, OnKeyRelease) ); } } @@ -3441,12 +3442,6 @@ void SAL_CALL FmXGridCell::removePaintListener( const Reference< awt::XPaintList OSL_FAIL( "FmXGridCell::removePaintListener: not implemented" ); } -IMPL_LINK( FmXGridCell, OnWindowEvent, VclWindowEvent&, _rEvent, void ) -{ - ENSURE_OR_THROW( _rEvent.GetWindow(), "illegal window" ); - onWindowEvent(_rEvent.GetId(), _rEvent.GetData()); -} - void FmXGridCell::onFocusGained( const awt::FocusEvent& _rEvent ) { checkDisposed(OComponentHelper::rBHelper.bDisposed); @@ -3523,25 +3518,23 @@ IMPL_LINK(FmXGridCell, OnMouseMove, const MouseEvent&, rMouseEvent, void) } } -void FmXGridCell::onWindowEvent(const VclEventId _nEventId, const void* _pEventData) +IMPL_LINK(FmXGridCell, OnKeyInput, const KeyEvent&, rEventData, void) { - switch ( _nEventId ) - { - case VclEventId::WindowKeyInput: - case VclEventId::WindowKeyUp: - { - if ( !m_aKeyListeners.getLength() ) - break; + if (!m_aKeyListeners.getLength()) + return; - const bool bKeyPressed = ( _nEventId == VclEventId::WindowKeyInput ); - awt::KeyEvent aEvent( VCLUnoHelper::createKeyEvent( *static_cast< const ::KeyEvent* >( _pEventData ), *this ) ); - m_aKeyListeners.notifyEach( bKeyPressed ? &awt::XKeyListener::keyPressed: &awt::XKeyListener::keyReleased, aEvent ); - } - break; - default: break; - } + awt::KeyEvent aEvent(VCLUnoHelper::createKeyEvent(rEventData, *this)); + m_aKeyListeners.notifyEach(&awt::XKeyListener::keyPressed, aEvent); } +IMPL_LINK(FmXGridCell, OnKeyRelease, const KeyEvent&, rEventData, void) +{ + if (!m_aKeyListeners.getLength()) + return; + + awt::KeyEvent aEvent(VCLUnoHelper::createKeyEvent(rEventData, *this)); + m_aKeyListeners.notifyEach(&awt::XKeyListener::keyReleased, aEvent); +} void FmXDataCell::PaintFieldToCell(OutputDevice& rDev, const tools::Rectangle& rRect, const Reference< css::sdb::XColumn >& _rxField, @@ -3550,7 +3543,6 @@ void FmXDataCell::PaintFieldToCell(OutputDevice& rDev, const tools::Rectangle& r m_pCellControl->PaintFieldToCell( rDev, rRect, _rxField, xFormatter ); } - void FmXDataCell::UpdateFromColumn() { Reference< css::sdb::XColumn > xField(m_pColumn->GetCurrentFieldValue()); @@ -3558,14 +3550,12 @@ void FmXDataCell::UpdateFromColumn() m_pCellControl->UpdateFromField(xField, m_pColumn->GetParent().getNumberFormatter()); } - FmXTextCell::FmXTextCell( DbGridColumn* pColumn, std::unique_ptr<DbCellControl> pControl ) :FmXDataCell( pColumn, std::move(pControl) ) ,m_bIsMultiLineText(false) { } - void FmXTextCell::PaintFieldToCell(OutputDevice& rDev, const tools::Rectangle& rRect, const Reference< css::sdb::XColumn >& _rxField, diff --git a/svx/source/inc/gridcell.hxx b/svx/source/inc/gridcell.hxx index 17cf26707712..9ee419ea18a8 100644 --- a/svx/source/inc/gridcell.hxx +++ b/svx/source/inc/gridcell.hxx @@ -763,8 +763,6 @@ public: { m_pCellControl->AlignControl(nAlignment);} protected: - void onWindowEvent(const VclEventId _nEventId, const void* _pEventData); - // default implementations call our focus listeners, don't forget to call them if you override this virtual void onFocusGained( const css::awt::FocusEvent& _rEvent ); virtual void onFocusLost( const css::awt::FocusEvent& _rEvent ); @@ -776,8 +774,8 @@ private: DECL_LINK(OnMousePress, const MouseEvent&, void); DECL_LINK(OnMouseRelease, const MouseEvent&, void); DECL_LINK(OnMouseMove, const MouseEvent&, void); - - DECL_LINK( OnWindowEvent, VclWindowEvent&, void ); + DECL_LINK(OnKeyInput, const KeyEvent&, void); + DECL_LINK(OnKeyRelease, const KeyEvent&, void); }; |