gpui: Press enter, space to trigger click to focused element (#35075)

Release Notes:

- N/A

> Any user interaction that is equivalent to a click, such as pressing
the Space key or Enter key while the element is focused. Note that this
only applies to elements with a default key event handler, and
therefore, excludes other elements that have been made focusable by
setting the
[tabindex](https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes/tabindex)
attribute.

https://developer.mozilla.org/en-US/docs/Web/API/Element/click_event

---------

Co-authored-by: Anthony <anthony@zed.dev>
Co-authored-by: Mikayla Maki <mikayla.c.maki@gmail.com>
Co-authored-by: Umesh Yadav <23421535+imumesh18@users.noreply.github.com>
This commit is contained in:
Jason Lee 2025-08-06 06:15:30 +08:00 committed by GitHub
parent b7469f5bc3
commit 0025019db4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 231 additions and 63 deletions

View file

@ -8183,7 +8183,7 @@ impl Editor {
editor.set_breakpoint_context_menu(
row,
Some(position),
event.down.position,
event.position(),
window,
cx,
);
@ -8350,7 +8350,11 @@ impl Editor {
.icon_color(color)
.toggle_state(is_active)
.on_click(cx.listener(move |editor, e: &ClickEvent, window, cx| {
let quick_launch = e.down.button == MouseButton::Left;
let quick_launch = match e {
ClickEvent::Keyboard(_) => true,
ClickEvent::Mouse(e) => e.down.button == MouseButton::Left,
};
window.focus(&editor.focus_handle(cx));
editor.toggle_code_actions(
&ToggleCodeActions {
@ -8362,7 +8366,7 @@ impl Editor {
);
}))
.on_right_click(cx.listener(move |editor, event: &ClickEvent, window, cx| {
editor.set_breakpoint_context_menu(row, position, event.down.position, window, cx);
editor.set_breakpoint_context_menu(row, position, event.position(), window, cx);
}))
}