Open andres-erbsen opened 9 years ago
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.)
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...).
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...
@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
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.