forked from reya/gpui-native-kit
feat: add dropdown menu component
This commit is contained in:
@@ -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"]);
|
||||
|
||||
Reference in New Issue
Block a user