Bugfix: prevent activating disabled ribbon items

This commit is contained in:
auria.mg 2016-08-15 20:33:06 -04:00
parent 26d2bf847c
commit 63a82c915c
4 changed files with 27 additions and 1 deletions

View File

@ -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;

View File

@ -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.
*/

View File

@ -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,

View File

@ -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;
};
}