Permalink
Browse files

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.
  • Loading branch information...
1 parent 82a84ab commit b6c1a87ccf5b93eea567746a23e995eb94f204c9 @bradallred bradallred committed Dec 30, 2013
Showing with 8 additions and 0 deletions.
  1. +7 −0 gemrb/core/GUI/EventMgr.cpp
  2. +1 −0 gemrb/core/GUI/EventMgr.h
View
7 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;
View
1 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;

0 comments on commit b6c1a87

Please sign in to comment.