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

keybind widget #2763

Closed
wants to merge 4 commits into from
Closed

keybind widget #2763

wants to merge 4 commits into from

Conversation

hecrj
Copy link
Member

@hecrj hecrj commented Jan 29, 2025

This PR introduces a brand new widget: keybind.

A keybind widget can be used to trigger a click interaction on its contents when a certain Hotkey is pressed.

A Hotkey is a keyboard combination: a key, some modifiers, and an optional location. By default, hotkeys use keyboard::Modifiers::COMMAND as the trigger modifiers.

For instance:

keybind('s', button("Save").on_press(Message::Save))

This will display a save button that can be clicked with the mouse and also by pressing Ctrl+S (or ⌘+S on macOS). In both instances, a Save message will be produced.

@hecrj hecrj added feature New feature or request widget addition labels Jan 29, 2025
@hecrj hecrj added this to the 0.14 milestone Jan 29, 2025
@hecrj hecrj force-pushed the feature/keybind-widget branch from 337d209 to 6295e6e Compare January 29, 2025 01:26
@hecrj
Copy link
Member Author

hecrj commented Jan 29, 2025

I am scratching this idea.

Since keybind listens to key presses unconditionally, it is possible to write UIs with conflicting keybinds very easily.

The current Subscription approach is superior because the most natural design encourages a single source of truth for key presses.

@hecrj hecrj closed this Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addition feature New feature or request widget
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant