Add support for :active
on event box (#529)
This commit is contained in:
parent
39eeeff7cf
commit
d814edd0d5
1 changed files with 12 additions and 1 deletions
|
@ -634,7 +634,7 @@ fn build_gtk_scrolledwindow(bargs: &mut BuilderArgs) -> Result<gtk::ScrolledWind
|
||||||
|
|
||||||
const WIDGET_NAME_EVENTBOX: &str = "eventbox";
|
const WIDGET_NAME_EVENTBOX: &str = "eventbox";
|
||||||
/// @widget eventbox
|
/// @widget eventbox
|
||||||
/// @desc a container which can receive events and must contain exactly one child. Supports `:hover` css selectors.
|
/// @desc a container which can receive events and must contain exactly one child. Supports `:hover` and `:active` css selectors.
|
||||||
fn build_gtk_event_box(bargs: &mut BuilderArgs) -> Result<gtk::EventBox> {
|
fn build_gtk_event_box(bargs: &mut BuilderArgs) -> Result<gtk::EventBox> {
|
||||||
let gtk_widget = gtk::EventBox::new();
|
let gtk_widget = gtk::EventBox::new();
|
||||||
|
|
||||||
|
@ -653,6 +653,17 @@ fn build_gtk_event_box(bargs: &mut BuilderArgs) -> Result<gtk::EventBox> {
|
||||||
gtk::Inhibit(false)
|
gtk::Inhibit(false)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Support :active selector
|
||||||
|
gtk_widget.connect_button_press_event(|gtk_widget, _| {
|
||||||
|
gtk_widget.clone().set_state_flags(gtk::StateFlags::ACTIVE, false);
|
||||||
|
gtk::Inhibit(false)
|
||||||
|
});
|
||||||
|
|
||||||
|
gtk_widget.connect_button_release_event(|gtk_widget, _| {
|
||||||
|
gtk_widget.clone().unset_state_flags(gtk::StateFlags::ACTIVE);
|
||||||
|
gtk::Inhibit(false)
|
||||||
|
});
|
||||||
|
|
||||||
def_widget!(bargs, _g, gtk_widget, {
|
def_widget!(bargs, _g, gtk_widget, {
|
||||||
// @prop timeout - timeout of the command
|
// @prop timeout - timeout of the command
|
||||||
// @prop onscroll - event to execute when the user scrolls with the mouse over the widget. The placeholder `{}` used in the command will be replaced with either `up` or `down`.
|
// @prop onscroll - event to execute when the user scrolls with the mouse over the widget. The placeholder `{}` used in the command will be replaced with either `up` or `down`.
|
||||||
|
|
Loading…
Add table
Reference in a new issue