hi
im writing again because i cant find solution to my GTK4 problem. i have action with parameter and cant find a way to connect either shortcut or accelerator to bind action and parameter.
i have an app that user creates forms. i solved parameter to bind with action with menu items. now i would like to add shortcuts to this action with parameter. and i cant find a way
Hi after some heavy reading i managed to get it working it even connects to menu items with designated parameter. this code should be in applicationWindow …
Glib::VariantType* type = new Glib::VariantType("s");
add_action_with_parameter("data_template",*type, sigc::mem_fun(*this, &AppWindow::onMenuDataTemplates));
Glib::RefPtr<Gtk::ShortcutController> sct = Gtk::ShortcutController::create();
Glib::RefPtr<Gtk::ShortcutTrigger> st = Gtk::ShortcutTrigger::parse_string("F6");
Glib::RefPtr<Gtk::ShortcutAction> sa = Gtk::NamedAction::create("win.data_template");
Glib::Variant<std::string> val = Glib::Variant<std::string>(g_variant_new_string("some parameter"));
Glib::RefPtr<Gtk::Shortcut> sc = Gtk::Shortcut::create(st,sa);
sc->set_arguments(val);
sct->add_shortcut(sc);
add_controller(sct);