Fix a rare drag/drop issue

master
Eduardo Bart 12 years ago
parent 6ef44d462d
commit f4641333f4

@ -42,10 +42,7 @@ protected:
}; };
/// Throws a generic exception /// Throws a generic exception
template<typename... T> inline void throw_exception(const std::string& what) { throw exception(what); }
void throw_exception(const std::string& what) {
throw exception(what);
}
} }

@ -133,7 +133,7 @@ void UIManager::inputEvent(const InputEvent& event)
} }
// mouse move can change hovered widgets // mouse move can change hovered widgets
updateHoveredWidget(); updateHoveredWidget(true);
// first fire dragging move // first fire dragging move
if(m_draggingWidget) { if(m_draggingWidget) {
@ -209,12 +209,12 @@ bool UIManager::updateDraggingWidget(const UIWidgetPtr& draggingWidget, const Po
return accepted; return accepted;
} }
void UIManager::updateHoveredWidget() void UIManager::updateHoveredWidget(bool now)
{ {
if(m_hoverUpdateScheduled) if(m_hoverUpdateScheduled && !now)
return; return;
g_dispatcher.addEvent([this] { auto func = [this] {
if(!m_rootWidget) if(!m_rootWidget)
return; return;
@ -235,8 +235,14 @@ void UIManager::updateHoveredWidget()
hoveredWidget->onHoverChange(true); hoveredWidget->onHoverChange(true);
} }
} }
}); };
m_hoverUpdateScheduled = true;
if(now)
func();
else {
m_hoverUpdateScheduled = true;
g_dispatcher.addEvent(func);
}
} }
void UIManager::onWidgetAppear(const UIWidgetPtr& widget) void UIManager::onWidgetAppear(const UIWidgetPtr& widget)

@ -41,7 +41,7 @@ public:
void updatePressedWidget(const UIWidgetPtr& newPressedWidget, const Point& clickedPos = Point()); void updatePressedWidget(const UIWidgetPtr& newPressedWidget, const Point& clickedPos = Point());
bool updateDraggingWidget(const UIWidgetPtr& draggingWidget, const Point& clickedPos = Point()); bool updateDraggingWidget(const UIWidgetPtr& draggingWidget, const Point& clickedPos = Point());
void updateHoveredWidget(); void updateHoveredWidget(bool now = false);
void clearStyles(); void clearStyles();
bool importStyle(const std::string& file); bool importStyle(const std::string& file);

Loading…
Cancel
Save