Fix wxRibbon tooltips: show them only once and not over dropdown

Don't update wxRibbonToolBar and wxRibbonButtonBar tooltips each time
the mouse was moved, this was inconsistent with the standard tooltips
behaviour and resulted in flicker.

Also don't show tooltips at all over a dropdown, as they partially
covered and, again, such behaviour is very non-standard.

Closes https://github.com/wxWidgets/wxWidgets/pull/2162
This commit is contained in:
Gary Allen
2021-01-10 17:47:44 +02:00
committed by Vadim Zeitlin
parent b980e2e859
commit ca4acfdffa
2 changed files with 14 additions and 4 deletions

View File

@@ -1298,6 +1298,8 @@ void wxRibbonButtonBar::OnMouseMove(wxMouseEvent& evt)
}
if(tooltipButton)
{
if (tooltipButton != m_hovered_button &&
!(tooltipButton->size & wxRIBBON_BUTTONBAR_BUTTON_DROPDOWN_ACTIVE))
SetToolTip(tooltipButton->base->help_string);
}
#else
@@ -1372,9 +1374,14 @@ void wxRibbonButtonBar::OnMouseDown(wxMouseEvent& evt)
cursor -= btn_rect.GetTopLeft();
long state = 0;
if(size.normal_region.Contains(cursor))
{
state = wxRIBBON_BUTTONBAR_BUTTON_NORMAL_ACTIVE;
}
else if(size.dropdown_region.Contains(cursor))
{
state = wxRIBBON_BUTTONBAR_BUTTON_DROPDOWN_ACTIVE;
UnsetToolTip();
}
instance.base->state |= state;
Refresh(false);
break;

View File

@@ -1078,6 +1078,8 @@ void wxRibbonToolBar::OnMouseMove(wxMouseEvent& evt)
#if wxUSE_TOOLTIPS
if(new_hover)
{
if (new_hover != m_hover_tool &&
!(new_hover->state & wxRIBBON_TOOLBAR_TOOL_DROPDOWN_ACTIVE))
SetToolTip(new_hover->help_string);
}
else if(GetToolTip())
@@ -1088,10 +1090,10 @@ void wxRibbonToolBar::OnMouseMove(wxMouseEvent& evt)
if(new_hover && new_hover->state & wxRIBBON_TOOLBAR_TOOL_DISABLED)
{
m_hover_tool = new_hover;
new_hover = NULL; // A disabled tool can not be hilighted
}
if(new_hover != m_hover_tool)
else if(new_hover != m_hover_tool)
{
if(m_hover_tool)
{
@@ -1143,6 +1145,7 @@ void wxRibbonToolBar::OnMouseDown(wxMouseEvent& evt)
m_active_tool = m_hover_tool;
m_active_tool->state |=
(m_active_tool->state & wxRIBBON_TOOLBAR_TOOL_HOVER_MASK) << 2;
UnsetToolTip();
Refresh(false);
}
}