From 0e394ed62e4a369bb57fe62137878d255c558cb0 Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Mon, 1 Oct 2012 14:26:43 +0100 Subject: [PATCH] Don't highlight menus when the mouse button is down. --- src/game/GameView.cpp | 3 ++- src/interface/Engine.cpp | 3 +++ src/interface/Engine.h | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/game/GameView.cpp b/src/game/GameView.cpp index 56f90e369..74a2b5a7f 100644 --- a/src/game/GameView.cpp +++ b/src/game/GameView.cpp @@ -446,7 +446,8 @@ public: MenuAction(GameView * _v, Menu * menu_) { v = _v; menu = menu_; } void MouseEnterCallback(ui::Button * sender) { - v->c->SetActiveMenu(menu); + if(!ui::Engine::Ref().GetMouseButton()) + v->c->SetActiveMenu(menu); } void ActionCallback(ui::Button * sender) { diff --git a/src/interface/Engine.cpp b/src/interface/Engine.cpp index aabbc62d2..643a02314 100644 --- a/src/interface/Engine.cpp +++ b/src/interface/Engine.cpp @@ -16,6 +16,7 @@ Engine::Engine(): state_(NULL), maxWidth(0), maxHeight(0), + mouseb_(0), mousex_(0), mousey_(0), mousexp_(0), @@ -260,12 +261,14 @@ void Engine::onKeyRelease(int key, Uint16 character, bool shift, bool ctrl, bool void Engine::onMouseClick(int x, int y, unsigned button) { + mouseb_ |= button; if(state_) state_->DoMouseDown(x, y, button); } void Engine::onMouseUnclick(int x, int y, unsigned button) { + mouseb_ &= ~button; if(state_) state_->DoMouseUp(x, y, button); } diff --git a/src/interface/Engine.h b/src/interface/Engine.h index c40f3a42c..b825eb898 100644 --- a/src/interface/Engine.h +++ b/src/interface/Engine.h @@ -53,6 +53,7 @@ namespace ui void SetFps(float fps); inline float GetFps() { return fps; }; + inline int GetMouseButton() { return mouseb_; } inline int GetMouseX() { return mousex_; } inline int GetMouseY() { return mousey_; } inline int GetWidth() { return width_; } @@ -89,6 +90,7 @@ namespace ui bool break_; int lastTick; + int mouseb_; int mousex_; int mousey_; int mousexp_;