use ui::context_menu::{ContextMenu, Place};
use ui::menu::Item;
// self.menu: ContextMenu<Self, usize>
div().id(("row", ix))
.on_mouse_down(MouseButton::Right, cx.listener(move |view, event: &MouseDownEvent, window, cx| {
view.menu.open(ix, Place::At(event.position),
vec![Item::action("Rename"), Item::action("Delete")],
move |view, path, window, cx| view.act(ix, path, window, cx),
window, cx);
}))
.children(self.menu.render_for(&ix, "row-menu", |view| &mut view.menu, window, cx))- The keys need
ui::menu::init(cx)at startup. - One
ContextMenuserves every menu in a view; the key names which is open, and opening one closes the rest. - A button that opens a menu calls
ContextMenu::toggleand is wrapped inContextMenu::trigger, or the press that shuts the menu opens it again. - Every
PlacebutAthangs off the elementrender_foris a child of, which isrelative(). For a sized card, usecardthenplace.
Keys
| key | does |
|---|---|
up / down |
walk the rows |
right, enter on a submenu row |
open it |
left |
close the submenu |
enter |
choose the row |
escape |
close the submenu, then the menu |