From 398f3df8af02047a76ab7172c69d93313250260c Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 29 Jan 2012 13:51:31 +0000 Subject: FS#80 Have mouse focus stick to the widget when the mouse button is down. --- src/ui/ui.cc | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/ui/ui.cc') diff --git a/src/ui/ui.cc b/src/ui/ui.cc index 4977d03..e10d77a 100644 --- a/src/ui/ui.cc +++ b/src/ui/ui.cc @@ -87,6 +87,8 @@ UI::UI() : Window(0) mouse_pointer_color = Palette::Pointer; mouse_pointer_bitmap.assign("pointer"); + + mouse_buttonleft_pressed = false; } UI::~UI() @@ -249,12 +251,18 @@ void UI::list_visible() const void UI::frame() { ui_input_focus = find_input_focus(); - Widget *f = find_mouse_focus(mouse_cursor); + + Widget *f = 0; + if (!mouse_buttonleft_pressed) { + f = find_mouse_focus(mouse_cursor); + } else { + f = find_visible_child(ui_mouse_focus); + } if (f) { f->event_mouse(mouse_cursor); } ui_mouse_focus = f; - + // reset mouse pointer ui::root()->set_pointer("pointer"); @@ -288,6 +296,9 @@ bool UI::input_key(const bool pressed, const int key, const unsigned int modifie ui_input_focus = f; } else if (key < 564) { + if ( key == 512 + SDL_BUTTON_LEFT) { + mouse_buttonleft_pressed = pressed; + } // mouse buttons Widget *f = find_mouse_focus(mouse_cursor); if (f) { -- cgit v1.2.3