Intercept option+key on Mac?

In an editable GtkTextView, in the context of a mathematical application, I’d like to have Alt+<letter> insert a Greek letter (a → alpha, b → beta and so on). This works fine, using (event->state & GDK_MOD1_MASK) for “Alt”, on Linux and Windows, but on macOS it seems that the combination of “option” (GDK_MOD1_MASK) + letter is already mapped by the OS to a weirdly miscellaneous set of special characters, so my app never sees (for example) GDK_MOD1_MASK along with plain ‘a’ or ‘b’.

My question: has anyone found a way to get the GTK stack to intercept and countermand option-inflected keystrokes on Mac?

Easy enough, it turns out. Put in some debugging to see what keysyms (guints) you actually get when doing option+letter on Mac, for letter = a…z and A…Z. Map those back to GDK_Key_a etc., and then apply the mapping to Greek letters as usual. Here’s the lower case array:

static guint mac_lc_keys[26] = {
    229, 2239, 231, 2287, 65105, 2294, 169,
    511, 65106, 16785926, 16777946, 172,
    181, 65107, 248, 2032, 5053, 174, 223,
    2801, 65111, 2262, 16785937, 16785992,
    165, 2009

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.