Bugfix: prevent activating disabled ribbon items
This commit is contained in:
parent
26d2bf847c
commit
63a82c915c
@ -532,7 +532,8 @@ void EventHandler::sendEventToUser(GUIEngine::Widget* widget, std::string& name,
|
||||
|
||||
EventPropagation EventHandler::onWidgetActivated(GUIEngine::Widget* w, const int playerID)
|
||||
{
|
||||
if (!w->isActivated()) return EVENT_BLOCK;
|
||||
if (w->onActivationInput(playerID) == EVENT_BLOCK)
|
||||
return EVENT_BLOCK;
|
||||
|
||||
Widget* parent = w->m_event_handler;
|
||||
|
||||
|
@ -332,6 +332,8 @@ namespace GUIEngine
|
||||
|
||||
bool isActivated() const;
|
||||
|
||||
virtual EventPropagation onActivationInput(const int playerID) { return EVENT_LET; }
|
||||
|
||||
/**
|
||||
* Call to resize/move the widget. Not all widgets can resize gracefully.
|
||||
*/
|
||||
|
@ -666,6 +666,26 @@ void RibbonWidget::updateSelection()
|
||||
if (m_listener) m_listener->onSelectionChange();
|
||||
} // updateSelection
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
EventPropagation RibbonWidget::onActivationInput(const int playerID)
|
||||
{
|
||||
assert(m_magic_number == 0xCAFEC001);
|
||||
|
||||
if (m_deactivated)
|
||||
return EVENT_BLOCK;
|
||||
|
||||
if (m_selection[playerID] > -1 &&
|
||||
m_selection[playerID] < (int)(m_active_children.size()))
|
||||
{
|
||||
if (m_active_children[m_selection[playerID]].m_deactivated)
|
||||
{
|
||||
return EVENT_BLOCK;
|
||||
}
|
||||
}
|
||||
|
||||
return EVENT_LET;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
EventPropagation RibbonWidget::transmitEvent(Widget* w,
|
||||
const std::string& originator,
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
#include "guiengine/widget.hpp"
|
||||
#include "guiengine/widgets/icon_button_widget.hpp"
|
||||
#include "utils/cpp2011.hpp"
|
||||
#include "utils/leak_check.hpp"
|
||||
#include "utils/ptr_vector.hpp"
|
||||
|
||||
@ -192,6 +193,8 @@ namespace GUIEngine
|
||||
void removeChildNamed(const char* name);
|
||||
|
||||
PtrVector<Widget>& getRibbonChildren() { return m_children; }
|
||||
|
||||
virtual EventPropagation onActivationInput(const int playerID) OVERRIDE;
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user