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]: temporarily disable hotkeys or context based hotkeys #1595

Open
1 task done
trsommer opened this issue Nov 19, 2024 · 2 comments
Open
1 task done
Assignees
Labels
enhancement New feature or request

Comments

@trsommer
Copy link
Collaborator

trsommer commented Nov 19, 2024

Is there an existing issue for this?

  • I have searched the existing issues and checked the recent builds/commits

What would your feature do ?

A developer api to temporarily disable hotkeys.
When a user opens the Mask Editor and presses Ctrl+Z, the undo operation should affect the Mask Editor rather than triggering ComfyUI's global undo functionality.

A better alternative would be a developer API to create hotkeys that only affect a certain context. Context could be enabled and disabled.

Proposed workflow

// Usage example 1

app.extensionManager.disableKeybindings('commandId1');
app.extensionManager.enableKeybindings(['commandId1', 'commandId2']);

//Usage example 2

//create context and keybinding via app.registerExtension

app.extensionManager.enableHotkeyContext('contextId')
app.extensionManager.disableHotkeyContext('contextId')

Additional information

No response

┆Issue is synchronized with this Notion page by Unito

@trsommer trsommer added the enhancement New feature or request label Nov 19, 2024
@huchenlei huchenlei self-assigned this Nov 19, 2024
@huchenlei
Copy link
Member

huchenlei commented Nov 19, 2024

#1230 tries to manage redo/undo in the new keyboard shortcut system, however there are some tricky parts.

Is it possible for you to capture the event you care like Ctrl-Z on the mask editor elements and stop its propagation immediately now?

@trsommer
Copy link
Collaborator Author

trsommer commented Nov 20, 2024

We definitely need #1230 as it unifies the keyboard listener. However, it doesn't resolve the issue where all canvas keybindings can still be triggered from the mask editor (e.g. Ctrl + O). The new keyboard shortcut system managing undo and redo actions doesn't address that problem (at least I don't see how it does). They behave like all other keybindings now.

In my opinion, in the short term, the best solution is to disable certain hotkeys from triggering using a command or through app.registerExtension. In the long term, the ideal solution would be to define different hotkey contexts (e.g., one for the canvas, another for the mask editor, and possibly others). Each context would handle keybindings separately, ensuring that hotkeys do not trigger in the wrong context and allowing for double definitions of hotkeys. Users will likely want to change the mask editor keybindings as well, so there needs to be a way to do that in the settings.

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

No branches or pull requests

2 participants