I found this widget works with GDK_BUTTON_PRIMARY
only
How to make page activation on click GDK_BUTTON_MIDDLE
too?
Thanks
I found this widget works with GDK_BUTTON_PRIMARY
only
How to make page activation on click GDK_BUTTON_MIDDLE
too?
Thanks
Found how to assign all buttons by create new event controller, but still don’t understand how to activate the Notebook tab on click
// GtkNotebook Label widget
const auto controller = Gtk::GestureClick::create();
controller->set_button(
0 // all
);
add_controller(
controller
);
controller->signal_pressed().connect(
[this](int n, double x, double y)
{
activate(); // not works
}
);
upd. seems the answer is here:
thanks to
upd2.
this *code still does not work, lol
// Gtk::Notebook
const auto controller = Gtk::GestureClick::create();
controller->set_button(
GDK_BUTTON_MIDDLE
);
add_controller(
controller
);
controller->signal_pressed().connect(
[this](int n, double x, double y)
{
auto widget = pick(x, y);
if (NULL != widget)
{
auto i = page_num(*widget);
if (i >= 0) // -1, fails as not found
{
set_current_page(i);
}
}
}
);
Shouldn’t it be
auto i = page_num(widget);
?
Also, don’t mix the tab widget with the page widget:
Should look like this:
tab_widget = pick(x, y);
for page in gtk_notebook_get_pages ()
if page.tab == tab_widget
i = page_num(page.child);
set_current_page(i);
Thanks for advice, after some pause returned to this question, let me try again…
By the way, interesting, is it possible to assign few buttons to one GestureClick
, not create 2 separated controllers for primary and middle click?
No: you’re supposed to create a different event controller, since you’re likely going to have two different behaviours.
Thanks,
but what about close (or activate) tab on middle click?
I wonder pick(x, y)
is only one possible solution, but it’s super tricky, can’t believe there is no way to emit this signal to this Label, the parent GtkGizmo
, or assign one click controller to another one (if I can’t use few buttons for one GestureClick
)
Found this idea
but why so hard for simple task… thoughts make new action, assign it to the label widget and try to activate on middle click
libadwaita
does everything I want