feat: add dropdown menu component

This commit is contained in:
2026-11-08 17:03:38 +07:00
parent 11b29dc91a
commit d8663593b6
10 changed files with 1244 additions and 197 deletions
+8 -3
View File
@@ -78,9 +78,14 @@ fn right_click_opens_the_menu_and_items_activate() {
right_click(&mut visual, point(px(100.), px(30.)));
draw(&mut visual);
// The panel claims focus, so the first item is keyboard-highlighted.
// A pointer open arms no row, so Enter alone fires nothing.
visual.simulate_keystrokes("enter");
draw(&mut visual);
assert_eq!(*actions.borrow(), Vec::<&str>::new());
// The first down arms Rename; enter fires it and closes the menu.
visual.simulate_keystrokes("down enter");
draw(&mut visual);
assert_eq!(*actions.borrow(), vec!["rename"]);
// The menu closed with the choice, so Enter reports nothing more.
@@ -88,10 +93,10 @@ fn right_click_opens_the_menu_and_items_activate() {
draw(&mut visual);
assert_eq!(*actions.borrow(), vec!["rename"]);
// Right-click again reopens; Down reaches the second item.
// Right-click again reopens; two downs reach the second item.
right_click(&mut visual, point(px(100.), px(30.)));
draw(&mut visual);
visual.simulate_keystrokes("down");
visual.simulate_keystrokes("down down");
visual.simulate_keystrokes("enter");
draw(&mut visual);
assert_eq!(*actions.borrow(), vec!["rename", "delete"]);