Ignore mouse clicks that were made directly on ribbon toolbar instead of child elements

This commit is contained in:
Deve 2018-08-31 01:29:17 +02:00
parent 399b89730d
commit 8a579d9542
8 changed files with 24 additions and 7 deletions

View File

@ -821,7 +821,10 @@ EventPropagation EventHandler::onGUIEvent(const SEvent& event)
return EVENT_BLOCK;
}
w->onClick();
EventPropagation result = w->onClick();
if (result == EVENT_BLOCK)
return result;
// These events are only triggered by mouse (or so I hope)
// The player that owns the mouser receives "game master" priviledges

View File

@ -674,7 +674,7 @@ namespace GUIEngine
bool ok() const { return (m_magic_number == 0xCAFEC001); }
/** Gets called when the widget is active and got clicked. (Only works for button widgets for now.) */
virtual void onClick() { }
virtual EventPropagation onClick() { return EVENT_LET; }
virtual irr::core::dimension2di getDimension() const { return irr::core::dimension2di(m_w, m_h); }
};

View File

@ -112,10 +112,12 @@ void RatingBarWidget::setStepValuesByMouse(const core::position2di & mouse_posit
}
}
void RatingBarWidget::onClick()
EventPropagation RatingBarWidget::onClick()
{
if(m_allow_voting)
m_rating = m_hover_rating;
return EVENT_LET;
}

View File

@ -73,7 +73,7 @@ namespace GUIEngine
void setStepValuesByMouse(const core::position2di & mouse_position, const core::recti & stars_rect);
virtual void onClick();
virtual EventPropagation onClick();
void allowVoting() { m_allow_voting = true; }
};

View File

@ -779,6 +779,14 @@ EventPropagation RibbonWidget::mouseHovered(Widget* child,
return EVENT_BLOCK;
} // mouseHovered
EventPropagation RibbonWidget::onClick()
{
if (m_ribbon_type == RIBBON_TOOLBAR)
return EVENT_BLOCK;
return EVENT_LET;
}
// ----------------------------------------------------------------------------
const std::string& RibbonWidget::getSelectionIDString(const int playerID)
{

View File

@ -92,6 +92,8 @@ namespace GUIEngine
virtual EventPropagation focused(const int playerID) OVERRIDE;
virtual void unfocused(const int playerID, Widget* new_focus) OVERRIDE;
virtual EventPropagation onClick() OVERRIDE;
PtrVector<irr::gui::IGUIStaticText, REF> m_labels;
IRibbonListener* m_listener;

View File

@ -457,13 +457,13 @@ void SpinnerWidget::setCustomText(const core::stringw& text)
// -----------------------------------------------------------------------------
void SpinnerWidget::onClick()
EventPropagation SpinnerWidget::onClick()
{
if (m_children[1].m_deactivated ||
m_children[1].m_properties[PROP_ID] != "spinnerbody" ||
!isGauge())
{
return;
return EVENT_LET;
}
const core::position2di mouse_position
@ -487,6 +487,8 @@ void SpinnerWidget::onClick()
setValue(new_value);
}
return EVENT_LET;
}
// -----------------------------------------------------------------------------

View File

@ -96,7 +96,7 @@ namespace GUIEngine
virtual EventPropagation leftPressed(const int playerID);
/** \brief implementing method from base class Widget */
virtual void onClick();
virtual EventPropagation onClick();
/** When inferring widget size from its label length, this method will be called to
* if/how much space must be added to the raw label's size for the widget to be large enough */