Re: [gtk-osx-users] Is there a way to override default key bindings?
- From: John Ralls <jralls ceridwen us>
- To: Andrius <andriusr yahoo com>
- Cc: "gtk-osx-users-list gnome org" <gtk-osx-users-list gnome org>
- Subject: Re: [gtk-osx-users] Is there a way to override default key bindings?
- Date: Wed, 9 Oct 2013 12:40:32 -0700
On Oct 9, 2013, at 12:34 PM, Andrius <andriusr yahoo com> wrote:
Hi all,
I have one interesting issue that could not figure out how to solve. Using gtk+3.6.4 on MacOSX 10.8.4.
I want to override default key bindings for some widgets, most important are GtkEntry and GtkTextView. I
did search on forums, but nothing useful was found. Tried several things that are described in gtk+3 docs,
but it seems that nothing from these works on MacOSX:
1. Tried to but into gtk-keys.css following code:
@binding-set gtk-mac-cmd-c
{
bind "<meta>x" { "cut-clipboard" () };
bind "<meta>c" { "copy-clipboard" () };
bind "<meta>v" { "paste-clipboard" () };
unbind "<ctrl>x";
unbind "<ctrl>c";
unbind "<ctrl>v";
}
GtkEntry {
gtk-key-bindings: gtk-mac-cmd-c;
}
No effect, all actions on GtkEntry still are done with ctrl+...
2. Tried loading binding_set into program with GtkCssProvider like in this pseudocode:
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_path (provider, filename, &error)) ;
gtk_style_context_add_provider_for_screen (gdk_screen_get_default (), GTK_STYLE_PROVIDER (provider),
GTK_STYLE_PROVIDER_PRIORITY_USER);
The css file I am loading has binding-set like in #1. Again, binding did not changed, although styles that
were in css file were applied successfully. It looks that @binding-set rule is not processed for some
reason on MacOSX.
3. The only way that works is to connect key-press-event signal to the GtkEntry and handle cmd+...
combinations in signal callback manually. But this way I am having both ctrl+v and cmd+v doing the same
thing - pasting text, for example. And having to handle this for each widget separately is not something
that one would be wanting to do.
I am wondering if anybody knows solution to this problem... or is it know bug?
It was a Gtk bug, since fixed. Rebuilding with the latest modulesets will get you your command-key
accelerators and bindings back... with one caveat: Don't set use_quartz_accelerators to TRUE, because then
the menu accelerators grab the key binding before gtk can see it, and it gets sent to whatever window has
menu focus instead of the one that has keyboard focus.
Regards,
John Ralls
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]