Re: Cross-Language Accelerator Activation



Paisa Seeluangsawat <paisa@users.sourceforge.net> writes:
>
> Time to time, a user would hit Alt-# while using English layout,
> didn't see the menu activated, switch to Thai layout, and hit Alt-#
> again.  How can I make the first Alt-# work?
>

I'm not sure I got what you're saying correctly, but I'll describe how
Gtk+ handles shortcut and accelerator keys (for better description,
you might want to turn to gtk-i18n list, which I'm CCing here, since
they might want to correct me in a few places :).

When one presses a key, it is associated with a keycode, current
level and group. Group may be eg. Russian, Thai, English, etc
("-layout" in setxkbmap). There are usually two or three levels for
each group, most notable plain-level ("un-Shifted" -- lowercase
letters) and Shifted level (uppercase letters and other symbols you
get with Shift).

Keycode describes only the physical position of a key (this is a bit
imprecise, but will do for now I hope), so it is meaningless without
group and level information. But, when you choose specific
Group/Level, each keycode is associated with one keysym (much
terminology :).

So, when you press a key, Gtk+ looks first if there is a shortcut
using keysym from the *active* Group/Level. If there is, it activates
the shortcut and finishes processing.

If not, it walks through all other groups/levels you've got, and only
checks mapping for exactly the same keycode that you've pressed. As
soon as it finds one, it activates related shortcut, and finishes.

Something like this is also provided by XFree86 CVS (soon to be 4.4,
or is it already? ;).

> I noticed that I can activate English accelerators while using Russian
> keyboard layout ("gkb-xmmap ru-rev").  But I cannot activate Russian
> accelerators while using English layout.  What make it work one way
> and not the other?
>
> I use 'setxkbmap th' for Thai layout ('gkb-xmmap th' doesn't work).
> Thai<=>English cross-language accelerator activation doesn't work
> either way.

So, answer to your question is to use multilayout features of XFree86
4.3 and newer, and try eg.

  setxkbmap -layout th,en_US -option "grp:shift_toggle"

This will load "th" into Group1, and en_US into Group2, and set both
Shift keys to switch group when pressed together.

And yes, shortcuts should work in both directions with this. ;)

If you've got older XFree86 than 4.3, or some other X server, you may
want to customize th map to include English keys in another group. If
you don't know how to create such a map, you may produce it on any
XFree86 4.3 server with 
 setxkbmap -layout th,en_US -print | xkbcomp -xkb -o combined-map.xkb
which you can later load into any X server you wish.


Hope this explains it and takes you to solution faster; feel free to
follow up with more questions, but to a more appropriate forum
(gtk-i18n seems a reasonable place for that).

Cheers,
Danilo



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