summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-09-08 15:21:10 +0100
committerCaolán McNamara <caolanm@redhat.com>2020-09-08 21:27:08 +0200
commitd05c1459f5b8150654ca0b7098cc331ba6009e07 (patch)
treebde0424008b8a92f0df9d5d24788139586215d59
parent18939aadf534f97b3650544345957a0bea46825c (diff)
tdf#136208 make combo/list/spin take focus on use of scroll wheel
So using the scrollwheel on those widgets when they do not have focus will cause then to take focus. That will then cause the fontsize/fontname widgets to reset back to the current document size/name if they are scrolled to a new value, but their new value not explicitly applied to the current document, when focus is restored to the document window. Change-Id: I5d27e5e90c4d76d9cb3321878d82e22d40cacf81 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102261 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--vcl/inc/listbox.hxx2
-rw-r--r--vcl/source/control/combobox.cxx2
-rw-r--r--vcl/source/control/imp_listbox.cxx4
-rw-r--r--vcl/source/control/listbox.cxx2
-rw-r--r--vcl/source/control/spinfld.cxx3
5 files changed, 9 insertions, 4 deletions
diff --git a/vcl/inc/listbox.hxx b/vcl/inc/listbox.hxx
index 0485001216b0..4d714e418d81 100644
--- a/vcl/inc/listbox.hxx
+++ b/vcl/inc/listbox.hxx
@@ -427,7 +427,7 @@ public:
sal_Int32 GetCurrentPos() const { return maLBWindow->GetCurrentPos(); }
bool ProcessKeyInput( const KeyEvent& rKEvt ) { return maLBWindow->ProcessKeyInput( rKEvt ); }
- bool HandleWheelAsCursorTravel( const CommandEvent& rCEvt );
+ bool HandleWheelAsCursorTravel(const CommandEvent& rCEvt, Control& rControl);
/**
* Removes existing separators, and sets the position of the
diff --git a/vcl/source/control/combobox.cxx b/vcl/source/control/combobox.cxx
index 00764d68bf12..b5b14d833d9d 100644
--- a/vcl/source/control/combobox.cxx
+++ b/vcl/source/control/combobox.cxx
@@ -784,7 +784,7 @@ bool ComboBox::EventNotify( NotifyEvent& rNEvt )
)
)
{
- bDone = m_pImpl->m_pImplLB->HandleWheelAsCursorTravel( *rNEvt.GetCommandEvent() );
+ bDone = m_pImpl->m_pImplLB->HandleWheelAsCursorTravel(*rNEvt.GetCommandEvent(), *this);
}
else
{
diff --git a/vcl/source/control/imp_listbox.cxx b/vcl/source/control/imp_listbox.cxx
index e25a506c6a48..a11d0eb8ba7c 100644
--- a/vcl/source/control/imp_listbox.cxx
+++ b/vcl/source/control/imp_listbox.cxx
@@ -2402,7 +2402,7 @@ const Wallpaper& ImplListBox::GetDisplayBackground() const
return maLBWindow->GetDisplayBackground();
}
-bool ImplListBox::HandleWheelAsCursorTravel( const CommandEvent& rCEvt )
+bool ImplListBox::HandleWheelAsCursorTravel(const CommandEvent& rCEvt, Control& rControl)
{
bool bDone = false;
if ( rCEvt.GetCommand() == CommandEventId::Wheel )
@@ -2410,6 +2410,8 @@ bool ImplListBox::HandleWheelAsCursorTravel( const CommandEvent& rCEvt )
const CommandWheelData* pData = rCEvt.GetWheelData();
if( !pData->GetModifier() && ( pData->GetMode() == CommandWheelMode::SCROLL ) )
{
+ if (!rControl.HasChildPathFocus())
+ rControl.GrabFocus();
sal_uInt16 nKey = ( pData->GetDelta() < 0 ) ? KEY_DOWN : KEY_UP;
KeyEvent aKeyEvent( 0, vcl::KeyCode( nKey ) );
bDone = ProcessKeyInput( aKeyEvent );
diff --git a/vcl/source/control/listbox.cxx b/vcl/source/control/listbox.cxx
index fbada6496e89..a82e4ce0fb11 100644
--- a/vcl/source/control/listbox.cxx
+++ b/vcl/source/control/listbox.cxx
@@ -883,7 +883,7 @@ bool ListBox::PreNotify( NotifyEvent& rNEvt )
)
)
{
- bDone = mpImplLB->HandleWheelAsCursorTravel( *rNEvt.GetCommandEvent() );
+ bDone = mpImplLB->HandleWheelAsCursorTravel(*rNEvt.GetCommandEvent(), *this);
}
else
{
diff --git a/vcl/source/control/spinfld.cxx b/vcl/source/control/spinfld.cxx
index d9298ae1598a..f63c037d6e9d 100644
--- a/vcl/source/control/spinfld.cxx
+++ b/vcl/source/control/spinfld.cxx
@@ -554,6 +554,9 @@ bool SpinField::EventNotify(NotifyEvent& rNEvt)
else
Up();
bDone = true;
+
+ if (!HasChildPathFocus())
+ GrabFocus();
}
}
else