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

Feature request: keyboard events from Window (keyboard shortcuts) #66

Open
andres-erbsen opened this issue Dec 16, 2014 · 5 comments
Open

Comments

@andres-erbsen
Copy link

It would be great if there was a way to detect keyboard when the application window has focus, not just when an Area has focus. The use cases I have in mind.

  • Enter to execute/start/send something
  • Ctrl-O to open an external file picker
@andlabs
Copy link
Owner

andlabs commented Dec 17, 2014

Keyboard shortcuts will come when I figure out how to do menu syntax; the two will be tied together. (I'm not sure what a good syntax would be; if you have any ideas let me know.)

@andres-erbsen
Copy link
Author

Here is an idea of mine, loosely based on the corresponding Qt Quick interface.

type MenuItem struct { // this would be in package ui
    Name      string
    Image      image.Image
    Modifiers ui.Modifiers
    Key       byte
    Handler   func()
    Submenu   []MenuItem
}

var mainMenu = NewMenu([]MenuItem{
    {"File", nil, ui.Alt, 'f', nil, []MenuItem{
        {"Open", nil, ui.Ctrl, 'o', func() { println("LaunchFilePicker()") }, nil},
        {"Quit", nil, ui.Ctrl | ui.Shift, 'q', ui.Stop, nil},
    }},
    {"About", nil, ui.Alt, 'a', func() { println("written by me") }, nil},
})

One weakness of this approach is that adding a new property to MenuItem would break all code written this way (using field names in the literals would help...).

@andlabs
Copy link
Owner

andlabs commented Mar 25, 2018

Ctrl-O is now andlabs/libui#321.

Enter on a window is a different thing I have to think about under what conditions it doesn't Just Work...

@ghost
Copy link

ghost commented Mar 3, 2020

@andlabs if windows part is the only issue preventing you from implementing key events handling in the entry i have it in the libui part. But i'm struggling with the go ui binding.
Could you have a look if you have time so we can merge our knowledge and get this feature done

Looks like i've found an issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants