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>
This commit is contained in:
parent
a7084f156a
commit
1e531c3160
5 changed files with 108 additions and 35 deletions
|
@ -184,13 +184,34 @@ namespace svt
|
|||
m_aFocusOutHdl = rHdl;
|
||||
}
|
||||
|
||||
void SetMousePressHdl(const Link<const MouseEvent&,void>& rHdl)
|
||||
{
|
||||
m_aMousePressHdl = rHdl;
|
||||
}
|
||||
|
||||
void SetMouseReleaseHdl(const Link<const MouseEvent&,void>& rHdl)
|
||||
{
|
||||
m_aMouseReleaseHdl = rHdl;
|
||||
}
|
||||
|
||||
void SetMouseMoveHdl(const Link<const MouseEvent&,void>& rHdl)
|
||||
{
|
||||
m_aMouseMoveHdl = rHdl;
|
||||
}
|
||||
|
||||
protected:
|
||||
DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
|
||||
DECL_LINK(FocusInHdl, weld::Widget&, void);
|
||||
DECL_LINK(FocusOutHdl, weld::Widget&, void);
|
||||
DECL_LINK(MousePressHdl, const MouseEvent&, bool);
|
||||
DECL_LINK(MouseReleaseHdl, const MouseEvent&, bool);
|
||||
DECL_LINK(MouseMoveHdl, const MouseEvent&, bool);
|
||||
private:
|
||||
Link<LinkParamNone*,void> m_aFocusInHdl;
|
||||
Link<LinkParamNone*,void> m_aFocusOutHdl;
|
||||
Link<const MouseEvent&,void> m_aMousePressHdl;
|
||||
Link<const MouseEvent&,void> m_aMouseReleaseHdl;
|
||||
Link<const MouseEvent&,void> m_aMouseMoveHdl;
|
||||
};
|
||||
|
||||
class SVT_DLLPUBLIC EditControlBase : public ControlBase
|
||||
|
|
|
@ -32,6 +32,9 @@ namespace svt
|
|||
m_xWidget->connect_key_press(LINK(this, ControlBase, KeyInputHdl));
|
||||
m_xWidget->connect_focus_in(LINK(this, ControlBase, FocusInHdl));
|
||||
m_xWidget->connect_focus_out(LINK(this, ControlBase, FocusOutHdl));
|
||||
m_xWidget->connect_mouse_press(LINK(this, ControlBase, MousePressHdl));
|
||||
m_xWidget->connect_mouse_release(LINK(this, ControlBase, MouseReleaseHdl));
|
||||
m_xWidget->connect_mouse_move(LINK(this, ControlBase, MouseMoveHdl));
|
||||
}
|
||||
|
||||
void ComboBoxControl::dispose()
|
||||
|
@ -119,6 +122,9 @@ namespace svt
|
|||
m_xWidget->connect_key_press(LINK(this, ControlBase, KeyInputHdl));
|
||||
m_xWidget->connect_focus_in(LINK(this, ControlBase, FocusInHdl));
|
||||
m_xWidget->connect_focus_out(LINK(this, ControlBase, FocusOutHdl));
|
||||
m_xWidget->connect_mouse_press(LINK(this, ControlBase, MousePressHdl));
|
||||
m_xWidget->connect_mouse_release(LINK(this, ControlBase, MouseReleaseHdl));
|
||||
m_xWidget->connect_mouse_move(LINK(this, ControlBase, MouseMoveHdl));
|
||||
}
|
||||
|
||||
void ListBoxControl::dispose()
|
||||
|
@ -189,6 +195,9 @@ namespace svt
|
|||
m_xBox->connect_key_press(LINK(this, ControlBase, KeyInputHdl));
|
||||
m_xBox->connect_focus_in(LINK(this, ControlBase, FocusInHdl));
|
||||
m_xBox->connect_focus_out(LINK(this, ControlBase, FocusOutHdl));
|
||||
m_xBox->connect_mouse_press(LINK(this, ControlBase, MousePressHdl));
|
||||
m_xBox->connect_mouse_release(LINK(this, ControlBase, MouseReleaseHdl));
|
||||
m_xBox->connect_mouse_move(LINK(this, ControlBase, MouseMoveHdl));
|
||||
m_xBox->connect_toggled(LINK(this, CheckBoxControl, OnToggle));
|
||||
}
|
||||
|
||||
|
@ -342,6 +351,9 @@ namespace svt
|
|||
m_pEntry->connect_key_press(LINK(this, ControlBase, KeyInputHdl));
|
||||
m_pEntry->connect_focus_in(LINK(this, ControlBase, FocusInHdl));
|
||||
connect_focus_out(LINK(this, ControlBase, FocusOutHdl));
|
||||
m_pEntry->connect_mouse_press(LINK(this, ControlBase, MousePressHdl));
|
||||
m_pEntry->connect_mouse_release(LINK(this, ControlBase, MouseReleaseHdl));
|
||||
m_pEntry->connect_mouse_move(LINK(this, ControlBase, MouseMoveHdl));
|
||||
}
|
||||
|
||||
bool ControlBase::ProcessKey(const KeyEvent& rKEvt)
|
||||
|
@ -366,6 +378,24 @@ namespace svt
|
|||
static_cast<BrowserDataWin*>(GetParent())->GetParent()->ChildFocusOut();
|
||||
}
|
||||
|
||||
IMPL_LINK(ControlBase, MousePressHdl, const MouseEvent&, rEvent, bool)
|
||||
{
|
||||
m_aMousePressHdl.Call(rEvent);
|
||||
return false;
|
||||
}
|
||||
|
||||
IMPL_LINK(ControlBase, MouseReleaseHdl, const MouseEvent&, rEvent, bool)
|
||||
{
|
||||
m_aMouseReleaseHdl.Call(rEvent);
|
||||
return false;
|
||||
}
|
||||
|
||||
IMPL_LINK(ControlBase, MouseMoveHdl, const MouseEvent&, rEvent, bool)
|
||||
{
|
||||
m_aMouseMoveHdl.Call(rEvent);
|
||||
return false;
|
||||
}
|
||||
|
||||
void EditControlBase::dispose()
|
||||
{
|
||||
m_pEntry = nullptr;
|
||||
|
@ -640,6 +670,9 @@ namespace svt
|
|||
m_xWidget->connect_key_press(LINK(this, ControlBase, KeyInputHdl));
|
||||
m_xWidget->connect_focus_in(LINK(this, ControlBase, FocusInHdl));
|
||||
m_xWidget->connect_focus_out(LINK(this, ControlBase, FocusOutHdl));
|
||||
m_xWidget->connect_mouse_press(LINK(this, ControlBase, MousePressHdl));
|
||||
m_xWidget->connect_mouse_release(LINK(this, ControlBase, MouseReleaseHdl));
|
||||
m_xWidget->connect_mouse_move(LINK(this, ControlBase, MouseMoveHdl));
|
||||
// so any the natural size doesn't have an effect
|
||||
m_xWidget->set_size_request(1, 1);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
IMPL_LINK(FmXGridCell, OnMousePress, const MouseEvent&, rEventData, void)
|
||||
{
|
||||
if (!m_aMouseListeners.getLength())
|
||||
return;
|
||||
|
||||
awt::MouseEvent aEvent(VCLUnoHelper::createMouseEvent(rEventData, *this));
|
||||
m_aMouseListeners.notifyEach(&awt::XMouseListener::mousePressed, aEvent);
|
||||
}
|
||||
|
||||
IMPL_LINK(FmXGridCell, OnMouseRelease, const MouseEvent&, rEventData, void)
|
||||
{
|
||||
if (!m_aMouseListeners.getLength())
|
||||
return;
|
||||
|
||||
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() )
|
||||
{
|
||||
if ( m_aMouseListeners.getLength() != 0 )
|
||||
{
|
||||
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() )
|
||||
{
|
||||
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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FmXGridCell::onWindowEvent(const VclEventId _nEventId, const void* _pEventData)
|
||||
{
|
||||
switch ( _nEventId )
|
||||
{
|
||||
case VclEventId::WindowMouseButtonDown:
|
||||
case VclEventId::WindowMouseButtonUp:
|
||||
{
|
||||
if ( !m_aMouseListeners.getLength() )
|
||||
break;
|
||||
|
||||
const bool bButtonDown = ( _nEventId == VclEventId::WindowMouseButtonDown );
|
||||
|
||||
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:
|
||||
{
|
||||
const MouseEvent& rMouseEvent = *static_cast< const ::MouseEvent* >( _pEventData );
|
||||
if ( rMouseEvent.IsEnterWindow() || rMouseEvent.IsLeaveWindow() )
|
||||
{
|
||||
if ( m_aMouseListeners.getLength() != 0 )
|
||||
{
|
||||
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() )
|
||||
{
|
||||
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 );
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case VclEventId::WindowKeyInput:
|
||||
case VclEventId::WindowKeyUp:
|
||||
{
|
||||
|
|
|
@ -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 );
|
||||
};
|
||||
|
||||
|
|
|
@ -12127,6 +12127,13 @@ private:
|
|||
pThis->signal_activate();
|
||||
}
|
||||
|
||||
virtual void ensureMouseEventWidget() override
|
||||
{
|
||||
// The GtkEntry is sufficient to get mouse events without an intermediate GtkEventBox
|
||||
if (!m_pMouseEventBox)
|
||||
m_pMouseEventBox = m_pDelegate;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
virtual void signal_activate()
|
||||
|
|
Loading…
Reference in a new issue