File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33using Terminal . Gui ;
44using Terminal . Gui . App ;
55using Terminal . Gui . Views ;
6+ using TerminalGuiDesigner . UI ;
67
78namespace TerminalGuiDesigner ;
89
@@ -295,6 +296,13 @@ private void ConvertEmptySubMenus(MenuItem menuItem)
295296 internal static MenuItem ? GetFocusedMenuItemIfAny ( IApplication app )
296297 {
297298 var m = app . Popovers ? . Popovers ? . FirstOrDefault ( p => p . Visible ) as PopoverMenu ;
299+
300+ // Don't let user edit the literal popup context menu in main app (that appears
301+ // when right clicking in empty space).
302+ if ( m ? . Data is string s && s == Editor . DesignerCorePopoverName )
303+ {
304+ return null ;
305+ }
298306
299307 var focused = m ? . Focused ;
300308
Original file line number Diff line number Diff line change @@ -65,6 +65,11 @@ public class Editor : Runnable, IErrorReporter
6565 /// </summary>
6666 public const string Error = "Error" ;
6767
68+ /// <summary>
69+ /// String to assign to popover data field so that we don't accidentally edit our own context menus!
70+ /// </summary>
71+ public const string ? DesignerCorePopoverName = "CoreDesignerPopupMenu" ;
72+
6873 /// <summary>
6974 /// Initializes a new instance of the <see cref="Editor"/> class.
7075 /// </summary>
@@ -1022,6 +1027,8 @@ private void CreateAndShowContextMenu(Mouse? m, Design? rightClicked)
10221027 }
10231028
10241029 var menu = new PopoverMenu ( all . ToArray ( ) ) ;
1030+ menu . Data = DesignerCorePopoverName ;
1031+
10251032 Point position ;
10261033 if ( m != null && m . Position . HasValue )
10271034 {
You can’t perform that action at this time.
0 commit comments