pub fn menu_trigger<V: 'static, T: 'static, E: StatefulInteractiveElement>(
el: E,
popup: impl Fn(&mut V) -> &mut Popup<T> + Copy + 'static,
value: impl Fn(&ClickEvent) -> T + 'static,
cx: &Context<'_, V>,
) -> EExpand description
Wire a trigger to the popup it toggles: press note on the way down, open or close on the way up.
The press/release split is why this exists rather than a plain
on_click. on_mouse_down_out fires on the press and on_click on the
release, so one physical click on the trigger of an open menu runs the
card’s dismissal first and the trigger’s toggle second — by which time the
state a toggle would branch on is already gone, and the menu reopens on the
click that shut it (user report). No click handler can tell the two apart;
the note has to be taken in the phase the dismissal cannot precede.
value is what to open with, from the click that opened it — a point for a
menu anchored where it was pressed, or move |_| .. for one that already
knows.
This is a true toggle either way: a card that dismisses itself on the out-press is already closing by the release and the close here is a no-op, while a card that does not (one dismissed by Escape alone, or one the trigger sits inside) is closed by the release itself.