Skip to content

Commit

Permalink
EventManager: allow dragging controls to retain focus
Browse files Browse the repository at this point in the history
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
bradallred committed Dec 31, 2013
1 parent 82a84ab commit b6c1a87
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
7 changes: 7 additions & 0 deletions gemrb/core/GUI/EventMgr.cpp
Expand Up @@ -50,6 +50,7 @@ EventMgr::EventMgr(void)
dc_delay = 250;
rk_delay = 250;
rk_flags = GEM_RK_DISABLE;
focusLock = NULL;
}

EventMgr::~EventMgr(void)
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}
}
Expand All @@ -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;
Expand Down
1 change: 1 addition & 0 deletions gemrb/core/GUI/EventMgr.h
Expand Up @@ -82,6 +82,7 @@ class Window;

class GEM_EXPORT EventMgr {
private:
Control* focusLock;
std::vector< Window*> windows;
std::vector< int> topwin;

Expand Down

0 comments on commit b6c1a87

Please sign in to comment.