Re: Disabling accelerators when typing text

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Actually, we are coding in GTKMM-2.4, but I will tell you what we did.

We have map of accelerator data: { Name }={ Action, Key, Modifier }
We have some MODE enumerator that could say which accelerators should be
active.

So, you need some activatable widgets (toolbarItem, menuItem, button,
etc), to use methods:

for( each entry in map )
{
  gtk_widget_add_accelerator() - when current MODE allow entry.KEY
  gtk_widget_remove_accelerator() - when current MODE disallow entry.KEY
}

https://developer.gnome.org/gtk3/stable/GtkWidget.html#gtk-widget-add-accelerator

So, you could add signal on FOCUS_IN to remove accelerators, and signal
on FOCUS_OUT to add accelerators.

В Сбт, 04/06/2016 в 21:34 +0200, productivememberofsociety666 пишет:
> Hello,
> 
> I just want to reask a question that was asked on StackOverflow [1] but
> didn't receive a satisfactory answer there. Maybe someone on this list
> has a better idea:
> 
> I want to use ordinary letters *without modifiers* as accelerators in my
> GTK+ 3 application, similar to vim's control scheme. For example, the
> user could just press 'r' and it would remove an item in a list or
> something like that.
> So far this works fine, except the accelerators are also enabled while
> the user has focused a text editing widget, and as a result it's
> impossible to write text without activating a dozen accelerators in the
> process.
> 
> Is there a standard way to disable accelerators in  text editing
> widgets? If not, what would you say is the best approach for a
> workaround? E.g. should I try to intercept key presses somehow and check
> whether a text editing widget is focused, or should I try to remove
> accelerators whenever such a widget is focused and add them again when
> it loses focus, or do something else entirely?
> 
> I'm using GTK+ 3 and try to adhere to the "new" recommended way of
> handling menu items, accelerators and corresponding actions using Gio,
> i.e. the way it is described in [2].
> 
> Thank you in advance!
> 
> [1]: http://stackoverflow.com/q/22782726/2748899
> 
> [2]: https://wiki.gnome.org/HowDoI/GAction
> 
> _______________________________________________
> gtk-list mailing list
> gtk-list@xxxxxxxxx
> https://mail.gnome.org/mailman/listinfo/gtk-list

Regards,

-Andrew


_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
https://mail.gnome.org/mailman/listinfo/gtk-list




[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux