group: proper fix of enter/leave
Ignore mouse leave event when we are still within the parent element
This commit is contained in:
parent
05d69ae822
commit
17f07b2452
|
@ -30,7 +30,6 @@ class Group : public AModule {
|
||||||
bool handleMouseEnter(GdkEventCrossing *const &ev) override;
|
bool handleMouseEnter(GdkEventCrossing *const &ev) override;
|
||||||
bool handleMouseLeave(GdkEventCrossing *const &ev) override;
|
bool handleMouseLeave(GdkEventCrossing *const &ev) override;
|
||||||
bool handleToggle(GdkEventButton *const &ev) override;
|
bool handleToggle(GdkEventButton *const &ev) override;
|
||||||
void addHoverHandlerTo(Gtk::Widget &widget);
|
|
||||||
void show_group();
|
void show_group();
|
||||||
void hide_group();
|
void hide_group();
|
||||||
};
|
};
|
||||||
|
|
|
@ -81,16 +81,9 @@ Group::Group(const std::string& name, const std::string& id, const Json::Value&
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addHoverHandlerTo(revealer);
|
|
||||||
event_box_.add(box);
|
event_box_.add(box);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Group::addHoverHandlerTo(Gtk::Widget& widget) {
|
|
||||||
widget.add_events(Gdk::EventMask::ENTER_NOTIFY_MASK | Gdk::EventMask::LEAVE_NOTIFY_MASK);
|
|
||||||
widget.signal_enter_notify_event().connect(sigc::mem_fun(*this, &Group::handleMouseEnter));
|
|
||||||
widget.signal_leave_notify_event().connect(sigc::mem_fun(*this, &Group::handleMouseLeave));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Group::show_group() {
|
void Group::show_group() {
|
||||||
box.set_state_flags(Gtk::StateFlags::STATE_FLAG_PRELIGHT);
|
box.set_state_flags(Gtk::StateFlags::STATE_FLAG_PRELIGHT);
|
||||||
revealer.set_reveal_child(true);
|
revealer.set_reveal_child(true);
|
||||||
|
@ -109,7 +102,7 @@ bool Group::handleMouseEnter(GdkEventCrossing* const& e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Group::handleMouseLeave(GdkEventCrossing* const& e) {
|
bool Group::handleMouseLeave(GdkEventCrossing* const& e) {
|
||||||
if (!click_to_reveal) {
|
if (!click_to_reveal && e->detail != GDK_NOTIFY_INFERIOR) {
|
||||||
hide_group();
|
hide_group();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in New Issue