Improve doc comments about keybinding order (#23014)

Release Notes:

- N/A
This commit is contained in:
Michael Sloan 2025-01-11 15:47:42 -07:00 committed by GitHub
parent daaa250109
commit 5785266c8c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 28 additions and 19 deletions

View file

@ -3077,7 +3077,8 @@ impl<'a> WindowContext<'a> {
false
}
/// Represent this action as a key binding string, to display in the UI.
/// Return a key binding string for an action, to display in the UI. Uses the highest precedence
/// binding for the action (last binding added to the keymap).
pub fn keystroke_text_for(&self, action: &dyn Action) -> String {
self.bindings_for_action(action)
.into_iter()
@ -3734,7 +3735,8 @@ impl<'a> WindowContext<'a> {
actions
}
/// Returns key bindings that invoke the given action on the currently focused element.
/// Returns key bindings that invoke an action on the currently focused element, in precedence
/// order (reverse of the order they were added to the keymap).
pub fn bindings_for_action(&self, action: &dyn Action) -> Vec<KeyBinding> {
self.window
.rendered_frame
@ -3745,12 +3747,16 @@ impl<'a> WindowContext<'a> {
)
}
/// Returns key bindings that invoke the given action on the currently focused element.
/// Returns key bindings that invoke the given action on the currently focused element, without
/// checking context. Bindings are returned returned in precedence order (reverse of the order
/// they were added to the keymap).
pub fn all_bindings_for_input(&self, input: &[Keystroke]) -> Vec<KeyBinding> {
RefCell::borrow(&self.keymap).all_bindings_for_input(input)
}
/// Returns any bindings that would invoke the given action on the given focus handle if it were focused.
/// Returns any bindings that would invoke an action on the given focus handle if it were
/// focused. Bindings are returned returned in precedence order (reverse of the order
/// they were added to the keymap).
pub fn bindings_for_action_in(
&self,
action: &dyn Action,