diff options
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/gui.cpp | 44 | ||||
-rw-r--r-- | src/gui/gui.h | 2 |
2 files changed, 45 insertions, 1 deletions
diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index dcb8d38cf..9418d3e4c 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -437,7 +437,6 @@ void Gui::draw() if (mouseCursor) { mouseCursor->setAlpha(mMouseCursorAlpha); - static_cast<Graphics*>(mGraphics)->drawImage( mouseCursor, mouseX - 15, @@ -730,6 +729,49 @@ void Gui::handleMouseInput() BLOCK_END("Gui::handleMouseInput") } +void Gui::handleMouseReleased(const gcn::MouseInput &mouseInput) +{ + gcn::Widget *sourceWidget = getMouseEventSource( + mouseInput.getX(), mouseInput.getY()); + + if (mFocusHandler->getDraggedWidget()) + { + if (sourceWidget != mFocusHandler->getLastWidgetPressed()) + mFocusHandler->setLastWidgetPressed(nullptr); + + sourceWidget = mFocusHandler->getDraggedWidget(); + } + + int sourceWidgetX, sourceWidgetY; + sourceWidget->getAbsolutePosition(sourceWidgetX, sourceWidgetY); + + distributeMouseEvent(sourceWidget, + MouseEvent::RELEASED, + mouseInput.getButton(), + mouseInput.getX(), + mouseInput.getY()); + + if (mouseInput.getButton() == mLastMousePressButton + && mFocusHandler->getLastWidgetPressed() == sourceWidget) + { + distributeMouseEvent(sourceWidget, + MouseEvent::CLICKED, + mouseInput.getButton(), + mouseInput.getX(), + mouseInput.getY()); + + mFocusHandler->setLastWidgetPressed(nullptr); + } + else + { + mLastMousePressButton = 0; + mClickCount = 0; + } + + if (mFocusHandler->getDraggedWidget()) + mFocusHandler->setDraggedWidget(nullptr); +} + void Gui::addGlobalFocusListener(gcn::FocusListener* focusListener) { mFocusListeners.push_back(focusListener); diff --git a/src/gui/gui.h b/src/gui/gui.h index ed6bf6774..94dbf638f 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -156,6 +156,8 @@ class Gui final : public gcn::Gui protected: void handleMouseMoved(const gcn::MouseInput &mouseInput); + void handleMouseReleased(const gcn::MouseInput &mouseInput); + void handleMouseInput(); void distributeMouseEvent(gcn::Widget* source, int type, int button, |