-
Notifications
You must be signed in to change notification settings - Fork 0
Discussion thread for shortcuts #3
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
base: master
Are you sure you want to change the base?
Conversation
|
@4ian I've added a very minimal implementation of the shortcut system - it's basically intended as a proof of concept or a prototype instead of actual code, so there are a few Flow errors too that I've ignored for now.
... and it's working. Something you might want to review: While shifting the palette implementation to ref-based approach, instead of adding another state for handling the whole dialog's type PaletteMode = 'closed' | 'command' | 'option';
const CommandPalette = React.forwardRef<{||}, CommandPaletteInterface>(
(props, ref) => {
... commandManager and useStyles ...
const [mode, setMode] = React.useState<PaletteMode>('closed');
const [
selectedCommand,
selectCommand,
] = React.useState<null | NamedCommandWithOptions>(null);
... rest of command palette ...
}
)...and then It looks simpler to use and less prone to bugs (to me, at least). But I haven't seen this pattern in the codebase yet, so I wonder if this is okay? |
|
@4ian We have a basic working version of keyboard shortcuts now! I've added a shortcut map field in the preferences, and added two supporting functions - one to reset this map to default value, and one to edit the shortcut of a particular command. Then, I've added a basic UI version of the shortcut customization tab in preferences dialog (my screen-recording tool ran into some issues, so please make do with screenshots 😅 ): All the functionality is working. The UI is not complete yet - I've yet to add the following:
Another thing to be done is decide exactly what kinds of shortcuts we are going to allow. For example,
To me, these points hint to something like keeping |
|
@4ian I'm adding the shortcut-specific reset to default button. I tried using RaisedButton for the edit shortcut button, and it looks like this: In my opinion, RaisedButton is taking a bit more space than I needed it to take - and combined with the filled variant, it seems too dominating. But then I guess a user would open this tab almost only when the user wants to change a shortcut so maybe this does makes sense. What do you think? |
|
Well this will probably generate "too much" raised button, so forget about it and let's go back to what you had previously. Thanks anyway for testing :) |
|
Sorry to be out of touch for the last few days. My system got into some serious issues due to a bad kernel or driver update, and after trying to fix it (in vain), I had to uninstall the OS and hop over to another one - took some time to get things running. Also lost a bit of work that I kept in a git stash but forgot to carry over. This was a week almost wasted, basically :( Some progress:
I've added default shortcuts for some main commands from each "area". They're mostly random - I'll try exploring shortcuts in other apps to get some sensible defaults, then I'll put it up on the forum for suggestions as you mentioned. |
Sorry to hear! That's always frustrating. A good reason for pushing regularly your changes to some branch your work in progress (you can do this on a private repo or a branch not assigned to a PR, just to keep these to you) - you never know when your computer will suddenly die 😬
Ok sounds good!
Sounds good too.
Yes I agree. I was originally thinking that the "Scene:" could be added by the ScopedCommandProvider, but actually this can "simply" be a
No shortcut is surely a bit more explicit :) |
|
I've added the shortcut clash logic and UI (will push a commit in a while). Here's a screenshot, which also shows the area-based categorisation of commands and shortcuts. Something to note: the EDIT: |
|
@4ian I tried implementing the "handled by Electron" logic, and it works fine... except for one issue - apparently Electron's shortcut system does not care if the user is typing something while a shortcut is pressed. Fair on their side I think, but causes a bit of trouble for us. Consider the user sets shortcut for creating a new project as single key I can see two options:
const getElectronHandler = (onLaunchCommand, commandName) => {
return () => {
if (isUserTyping()) return;
onLaunchCommand(commandName);
}
}The second option looks a bit hacky to me, though. What should I do? Is there another option? |
|
Nilay, as discussed let's take a look at:
|
That's the current behaviour - the previous commit adds this functionality so that on the desktop app,
Single-key shortcuts on both desktop and web app seem to be working pretty fine for me on Linux (except for the Electron issue, obviously). Will need some more testing though, yes.
Yup, will do that today. Shouldn't take much time.
I'll go for that once the above is done. |
|
Just pushed a commit that improves the UX of the detect shortcut dialog. Now it dynamically shows "Ctrl + ", "Ctrl + Shift +", etc as the user presses and releases keys. I haven't added "Not a valid shortcut" message - right now if the shortcut is invalid, only the "Set Shortcut" button gets disabled. I'll try adding the help message tomorrow. |
|
I just realised - is the "This shortcut is reserved by your browser" message in detect shortcut dialog really necessary? If we try to keep the default shortcuts avoiding browser-reserved shortcuts, users are anyway going to realise their custom shortcut is browser-reserved when they try pressing it in the detect shortcut dialog. This happened to me - I tried to set Adding a message is good for UX since some users may wonder why GDevelop "opened" a new tab, but not showing a message apparently does not add any big gaps either. Can we leave it as an improvement for later on? |
Yes, it's indeed likely that the user will understand when pressing the shortcut that this is somehow superseded by the browser. I think we're in a good state for going ahead with a PR to master branch? This will allow me to do a new review pass and have this part of the next release :) |
nilaymaj
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I've pulled upstream changes and resolved all conflicts. There are a couple of little issues to take care of before the PR:
|
A final point before I make the PR - since opening the command palette is now governed by the shortcuts system, I think the "Enable command palette" preference flag is obsolete now. Is it fine to remove that flag from preferences now? If a user does want to "disable" the command palette, the user can simply remove the palette keyboard shortcut. |
MUI's ListItem has slightly different HTML for normal items and items with secondary actions, so commands with and without shortcuts are rendered slightly different. Having both in story is better for testing.
|
This preference flag is indeed obsolete! You can remove it from the preferences and from the dialog :) |
f927389 to
92856d9
Compare






Created a new PR and branch for work on keyboard shortcuts, because the commit history on the original PR got a bit bloated up (and because a new PR is cleaner anyway). Haven't done any significant work on shortcuts yet though - something came up that I never knew would take two full days to finish 😅. I've just pulled the dialog open logic into a separate file (
UI/OpenedDialogChecker.js).So what I'm planning to do is to:
refanduseImperativeHandle.Ctrl+Shift+P(or null, if the keypress does not correspond to a proper keyboard shortcut).... and then finally check how well it works out!