Maps · View: a focused pin keeps focus off view
Each pin holds a keyed focus handle of its own, a Tab stop and pressable while its place is in view, so a focused pin that pans out of view keeps focus and the arrows go on panning, and a popup that scrolls away hands focus back to its pin wherever it lies. A popup whose place is off view takes no focus. Tests hold the tall card's cap and scrolling body, the map staying under its wheel, and markers refuse a repeated key.
This commit is contained in:
1 parent
5f1c8ff46a
commit
d1202a88e2
5 files changed
+153
-21
No files matched your search
+8
-7
@@ -46,12 +46,13 @@ impl MapMarker {
|
||||
self
|
||||
}
|
||||
|
||||
/// The pin with its tip at a view point; pressable when the map has a handler.
|
||||
/// The pin with its tip at a view point. With the map's handler it holds `focus` in view and out, and while `seen` it takes Tab and presses.
|
||||
pub(crate) fn place(
|
||||
self,
|
||||
owner: &ElementId,
|
||||
(x, y): (f32, f32),
|
||||
on_marker: Option<OnMarker>,
|
||||
press: Option<(FocusHandle, OnMarker)>,
|
||||
seen: bool,
|
||||
cx: &App,
|
||||
) -> AnyElement {
|
||||
let theme = cx.theme();
|
||||
@@ -67,12 +68,12 @@ impl MapMarker {
|
||||
.border_1()
|
||||
.border_color(gpui::transparent_black())
|
||||
.child(Icon::new(IconName::MapPin).size(IconSize::Xl).color(ink))
|
||||
.when_some(on_marker, |pin, on_marker| {
|
||||
.when_some(press, |pin, (focus, on_marker)| {
|
||||
let key = self.key.clone();
|
||||
pin.tab_index(0)
|
||||
.focus_ring(cx)
|
||||
.cursor_pointer()
|
||||
.on_click(move |_, window, cx| on_marker(&key, window, cx))
|
||||
pin.track_focus(&focus).focus_ring(cx).when(seen, |pin| {
|
||||
pin.cursor_pointer()
|
||||
.on_click(move |_, window, cx| on_marker(&key, window, cx))
|
||||
})
|
||||
});
|
||||
let point = || {
|
||||
div()
|
||||
|
||||
Reference in new issue
Block a user