From b6c1a87ccf5b93eea567746a23e995eb94f204c9 Mon Sep 17 00:00:00 2001 From: Brad Allred Date: Mon, 30 Dec 2013 16:34:42 -0700 Subject: [PATCH] EventManager: allow dragging controls to retain focus scrollbars specifically were annoying to use because you couldnt leave their bounds with the mouse. This enables us to leave the bounds of a control and still deliver MouseOver events to it. --- gemrb/core/GUI/EventMgr.cpp | 7 +++++++ gemrb/core/GUI/EventMgr.h | 1 + 2 files changed, 8 insertions(+) diff --git a/gemrb/core/GUI/EventMgr.cpp b/gemrb/core/GUI/EventMgr.cpp index d41293cfdf..a4d53d4d84 100644 --- a/gemrb/core/GUI/EventMgr.cpp +++ b/gemrb/core/GUI/EventMgr.cpp @@ -50,6 +50,7 @@ EventMgr::EventMgr(void) dc_delay = 250; rk_delay = 250; rk_flags = GEM_RK_DISABLE; + focusLock = NULL; } EventMgr::~EventMgr(void) @@ -179,6 +180,10 @@ void EventMgr::MouseMove(unsigned short x, unsigned short y) // for scrolling gc->OnGlobalMouseMove(x, y); } + if (focusLock) { + last_win_mousefocused->OnMouseOver(x, y); + return; + } std::vector< int>::iterator t; std::vector< Window*>::iterator m; for (t = topwin.begin(); t != topwin.end(); ++t) { @@ -288,6 +293,7 @@ void EventMgr::MouseDown(unsigned short x, unsigned short y, unsigned short Butt if (ctrl != NULL) { last_win_mousefocused->SetMouseFocused( ctrl ); ctrl->OnMouseDown( x - last_win_mousefocused->XPos - ctrl->XPos, y - last_win_mousefocused->YPos - ctrl->YPos, Button, Mod ); + focusLock = ctrl; return; } } @@ -312,6 +318,7 @@ void EventMgr::MouseDown(unsigned short x, unsigned short y, unsigned short Butt void EventMgr::MouseUp(unsigned short x, unsigned short y, unsigned short Button, unsigned short Mod) { + focusLock = NULL; MButtons &= ~Button; Control *last_ctrl_mousefocused = GetMouseFocusedControl(); if (last_ctrl_mousefocused == NULL) return; diff --git a/gemrb/core/GUI/EventMgr.h b/gemrb/core/GUI/EventMgr.h index 99ff1bf91f..a83db937ce 100644 --- a/gemrb/core/GUI/EventMgr.h +++ b/gemrb/core/GUI/EventMgr.h @@ -82,6 +82,7 @@ class Window; class GEM_EXPORT EventMgr { private: + Control* focusLock; std::vector< Window*> windows; std::vector< int> topwin;