File tree 2 files changed +40
-0
lines changed
2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -743,6 +743,11 @@ internal void NextMenu (bool isSubMenu = false, bool ignoreUseSubMenusSingleFram
743
743
return ;
744
744
}
745
745
746
+ if ( _selected == - 1 )
747
+ {
748
+ return ;
749
+ }
750
+
746
751
OpenMenu ( _selected ) ;
747
752
748
753
SelectEnabledItem (
@@ -984,6 +989,11 @@ internal void PreviousMenu (bool isSubMenu = false, bool ignoreUseSubMenusSingle
984
989
return ;
985
990
}
986
991
992
+ if ( _selected == - 1 )
993
+ {
994
+ return ;
995
+ }
996
+
987
997
OpenMenu ( _selected ) ;
988
998
989
999
if ( ! SelectEnabledItem (
Original file line number Diff line number Diff line change @@ -2105,4 +2105,34 @@ public void Mouse_Pressed_Released_Clicked (int button)
2105
2105
2106
2106
top . Dispose ( ) ;
2107
2107
}
2108
+
2109
+ [ Fact ]
2110
+ [ AutoInitShutdown ]
2111
+ public void Menu_Without_SubMenu_Is_Closed_When_Pressing_Key_Right_Or_Key_Left ( )
2112
+ {
2113
+ var cm = new ContextMenu ( ) ;
2114
+
2115
+ var menuItems = new MenuBarItem (
2116
+ [
2117
+ new ( "_New" , string . Empty , null ) ,
2118
+ new ( "_Save" , string . Empty , null )
2119
+ ]
2120
+ ) ;
2121
+ var top = new Toplevel ( ) ;
2122
+ Application . Begin ( top ) ;
2123
+
2124
+ cm . Show ( menuItems ) ;
2125
+ Assert . True ( cm . MenuBar ! . IsMenuOpen ) ;
2126
+
2127
+ Assert . True ( Application . RaiseKeyDownEvent ( Key . CursorRight ) ) ;
2128
+ Assert . False ( cm . MenuBar ! . IsMenuOpen ) ;
2129
+
2130
+ cm . Show ( menuItems ) ;
2131
+ Assert . True ( cm . MenuBar ! . IsMenuOpen ) ;
2132
+
2133
+ Assert . True ( Application . RaiseKeyDownEvent ( Key . CursorLeft ) ) ;
2134
+ Assert . False ( cm . MenuBar ! . IsMenuOpen ) ;
2135
+
2136
+ top . Dispose ( ) ;
2137
+ }
2108
2138
}
You can’t perform that action at this time.
0 commit comments