-
Notifications
You must be signed in to change notification settings - Fork 620
request: Support for keyboard shortcuts/accelerators in menus #89
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
Comments
That is planned, yes. I need to figure out how menus are going to work. Potential problem: on OS X, things like copy and paste not only require accelerators to be hooked, but also hooked to specific selectors ( |
Just extend the built-in menu types (e.g. |
somehow, i would prefer being able to attach the built-in action to the same action attached to the menu item. |
@aoloe I don't understand what you mean; could you clarify your comment please? |
i would prefer not to have a uiMenuAppendCopyItem in the same way i'm not fond of uiMenuAppendQuitItem (#32). a quick and dirty "draft" of my idea would be:
i don't know if it's clearer this way or an |
Ah. So how would your event work for copying while focus is on a uiEntry? Would I have to override the entry controls to intercept the request to copy? Also I forget how accelerators are done on GTK+; I think GtkActionGroup... |
my comment was about the idea of adding one more buil-in action, not about adding shortcuts... |
+1 (or rather +100) for "to feel native" Here is the macOS part (all native actions I could find) : case typeCopy:
item->item = [[NSMenuItem alloc] initWithTitle:toNSString(name) action:@selector(copy:) keyEquivalent:@"c"];
[m->menu addItem:item->item];
break;
case typePaste:
item->item = [[NSMenuItem alloc] initWithTitle:toNSString(name) action:@selector(paste:) keyEquivalent:@"v"];
[m->menu addItem:item->item];
break;
case typeCut:
item->item = [[NSMenuItem alloc] initWithTitle:toNSString(name) action:@selector(cut:) keyEquivalent:@"x"];
[m->menu addItem:item->item];
break;
case typeSelectAll:
item->item = [[NSMenuItem alloc] initWithTitle:toNSString(name) action:@selector(selectAll:) keyEquivalent:@"a"];
[m->menu addItem:item->item];
break;
//name is ignored for these
case typeUndo:
item->item = [[NSMenuItem alloc] initWithTitle:@"" action:@selector(undo:) keyEquivalent:@"z"];
[m->menu addItem:item->item];
break;
case typeRedo:
item->item = [[NSMenuItem alloc] initWithTitle:@"" action:@selector(redo:) keyEquivalent:@"Z"];
[m->menu addItem:item->item];
break;
case typeFullscreen:
item->item = [[NSMenuItem alloc] initWithTitle:@"" action:@selector(toggleFullScreen:) keyEquivalent:@"f"];
[item->item setKeyEquivalentModifierMask:(NSControlKeyMask | NSCommandKeyMask)];
[m->menu addItem:item->item];
break; It works fine, but Unix and Windows support is of course missing (should all of these function be reimplemented ?). gedit's code might be helpful: https://github.com/GNOME/gedit/blob/9a7f1542ce0fa5ddc23fc60c5848a80dd80bd8eb/gedit/gedit-commands-edit.c |
Regarding the naming: uiMenuItem *uiMenuAppendItem(uiMenu *m, const char *name){
return uiMenuAppendTypeItem(m, name, typeRegular)
}
uiMenuItem *uiMenuAppendTypeItem(uiMenu *m, const char *name, int type); (with type being a platform-independent enum) wouldn't require adding a function for every type (like |
Replaced with #321. |
This is needed to feel native on all platforms.
The text was updated successfully, but these errors were encountered: