attempt to fix 'mouseover' state not being selected

when the mouse is inside a child widget of a toggle_panel.

This currently only fixes it for label, image and grid childs. Maybe we
want can_mouse_focus to be false by default?
This commit is contained in:
gfgtdf 2016-01-20 17:44:10 +01:00
parent 233a2e2d5f
commit 6cf9790c02
5 changed files with 11 additions and 0 deletions

View file

@ -175,6 +175,9 @@ void tmouse_motion::signal_handler_sdl_mouse_motion(const event::tevent event,
}
} else {
twidget* mouse_over = owner_.find_at(coordinate, true);
while(mouse_over && !mouse_over->can_mouse_focus() && mouse_over->parent()) {
mouse_over = mouse_over->parent();
}
if(mouse_over) {
DBG_GUI_E << LOG_HEADER << "Firing: " << event << ".\n";
if(owner_.fire(event, *mouse_over, coordinate)) {

View file

@ -184,6 +184,7 @@ public:
return child(row, col).widget();
}
virtual bool can_mouse_focus() const OVERRIDE { return false; }
/***** ***** ***** ***** layout functions ***** ***** ***** *****/
/** See @ref twidget::layout_initialise. */

View file

@ -54,6 +54,8 @@ public:
return label();
}
virtual bool can_mouse_focus() const OVERRIDE { return false; }
/***** ***** ***** ***** layout functions ***** ***** ***** *****/
private:

View file

@ -63,6 +63,7 @@ public:
void set_link_color(const std::string & color);
virtual bool can_mouse_focus() const OVERRIDE { return false; }
private:
/**
* Possible states of the widget.

View file

@ -341,6 +341,10 @@ private:
virtual tpoint calculate_best_size() const = 0;
public:
/**
* Whether the mouse move/click event go 'through' this widget.
*/
virtual bool can_mouse_focus() const { return true; }
/**
* Can the widget wrap.
*