Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing gdk_keymap_translate_keyboard_state() #384

Closed
SilentGopherLnx opened this issue Jul 10, 2019 · 0 comments · Fixed by #559
Closed

Missing gdk_keymap_translate_keyboard_state() #384

SilentGopherLnx opened this issue Jul 10, 2019 · 0 comments · Fixed by #559

Comments

@SilentGopherLnx
Copy link

GTK app receive different keyboard codes for different keyboard layouts. For example my keyboard have english and russian layouts and so my russian key "Я" (1745) is at "Z" (122).
I want to use keyboard shortcuts (like Ctrl+Z/Ctrl+C/Ctrl/V and etc) in my GTK-3 app for any possible languages.

gdk_keymap_translate_keyboard_state() can be better then my "GTK_TranslateKeyLayoutEnglish"

func main_event_listener(event *gdk.Event){
    eventObject := &gdk.EventKey{event}
    key := eventObject.KeyVal()
    state := eventObject.State()
    key, state = GTK_TranslateKeyLayoutEnglish(key, state)
    if state == gdk.GDK_CONTROL_MASK {
        if key == gdk.KEY_z {
            //Ctrl+Z
        } 
        if key == gdk.KEY_c {
            //Ctrl+C
        }
        if key == gdk.KEY_v {
            //Ctrl+V
        }
    } else {
        if key == gdk.KEY_F5 {
            //F5
        }
        if key == gdk.KEY_Delete {
            //Delete
        }
    }
}

func GTK_TranslateKeyLayoutEnglish(key uint, state uint) (uint, uint) {
    key2 := key
    state2 := state
    if state2 > 8192 { //RUSSIAN Ctrl 8196 == English Ctrl 4
        state2 -= 8192
    }
    switch key {
    case gdk.KEY_Cyrillic_ya: //RUSSIAN 'я'
        key2 = gdk.KEY_z
    case gdk.KEY_Cyrillic_ef: //RUSSIAN 'ф'
        key2 = gdk.KEY_a
    case gdk.KEY_Cyrillic_che: //RUSSIAN 'ч'
        key2 = gdk.KEY_x
    case gdk.KEY_Cyrillic_es: //RUSSIAN 'с'
        key2 = gdk.KEY_c
    case gdk.KEY_Cyrillic_em: //RUSSIAN 'м'
        key2 = gdk.KEY_v
        //etc
    }
    return key2, state2
}
@SilentGopherLnx SilentGopherLnx changed the title Miissing gdk_keymap_translate_keyboard_state() Missing gdk_keymap_translate_keyboard_state() Jul 10, 2019
@andre-hub andre-hub added this to the V0.9.0 milestone Feb 13, 2020
MJacred added a commit to cubiest/gotk3 that referenced this issue Apr 14, 2020
@andre-hub andre-hub modified the milestones: V0.9.0, V0.5.2 Dec 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants