@@ -73,7 +73,7 @@ public MenuBar ()
73
73
Y = 0 ;
74
74
Width = Dim . Fill ( ) ;
75
75
Height = 1 ; // BUGBUG: Views should avoid setting Height as doing so implies Frame.Size == GetContentSize ().
76
- Menus = new MenuBarItem [ ] { } ;
76
+ Menus = [ ] ;
77
77
78
78
//CanFocus = true;
79
79
_selected = - 1 ;
@@ -556,10 +556,10 @@ internal void CloseAllMenus ()
556
556
557
557
private void CloseOtherOpenedMenuBar ( )
558
558
{
559
- if ( Application . Top is { } )
559
+ if ( SuperView is { } )
560
560
{
561
561
// Close others menu bar opened
562
- Menu ? menu = Application . Top . SubViews . FirstOrDefault ( v => v is Menu m && m . Host != this && m . Host . IsMenuOpen ) as Menu ;
562
+ Menu ? menu = SuperView . SubViews . FirstOrDefault ( v => v is Menu m && m . Host != this && m . Host . IsMenuOpen ) as Menu ;
563
563
menu ? . Host . CleanUp ( ) ;
564
564
}
565
565
}
@@ -595,7 +595,7 @@ internal bool CloseMenu (bool reopen, bool isSubMenu, bool ignoreUseSubMenusSing
595
595
case false :
596
596
if ( _openMenu is { } )
597
597
{
598
- Application . Top ? . Remove ( _openMenu ) ;
598
+ SuperView ? . Remove ( _openMenu ) ;
599
599
}
600
600
601
601
SetNeedsDraw ( ) ;
@@ -634,7 +634,7 @@ internal bool CloseMenu (bool reopen, bool isSubMenu, bool ignoreUseSubMenusSing
634
634
635
635
if ( OpenCurrentMenu is { } )
636
636
{
637
- Application . Top ? . Remove ( OpenCurrentMenu ) ;
637
+ SuperView ? . Remove ( OpenCurrentMenu ) ;
638
638
if ( Application . MouseGrabView == OpenCurrentMenu )
639
639
{
640
640
Application . UngrabMouse ( ) ;
@@ -822,7 +822,7 @@ internal void OpenMenu (int index, int sIndex = -1, MenuBarItem? subMenu = null!
822
822
823
823
if ( _openMenu is { } )
824
824
{
825
- Application . Top ? . Remove ( _openMenu ) ;
825
+ SuperView ? . Remove ( _openMenu ) ;
826
826
if ( Application . MouseGrabView == _openMenu )
827
827
{
828
828
Application . UngrabMouse ( ) ;
@@ -838,34 +838,23 @@ internal void OpenMenu (int index, int sIndex = -1, MenuBarItem? subMenu = null!
838
838
pos += Menus [ i ] . TitleLength + ( Menus [ i ] . Help . GetColumns ( ) > 0 ? Menus [ i ] . Help . GetColumns ( ) + 2 : 0 ) + _leftPadding + _rightPadding ;
839
839
}
840
840
841
- var locationOffset = Point . Empty ;
842
841
843
- // if SuperView is null then it's from a ContextMenu
844
- if ( SuperView is null )
845
- {
846
- locationOffset = GetScreenOffset ( ) ;
847
- }
848
842
849
- if ( SuperView is { } && SuperView != Application . Top )
850
- {
851
- locationOffset . X += SuperView . Border . Thickness . Left ;
852
- locationOffset . Y += SuperView . Border . Thickness . Top ;
853
- }
854
843
855
844
_openMenu = new ( )
856
845
{
857
846
Host = this ,
858
- X = Frame . X + pos + locationOffset . X ,
859
- Y = Frame . Y + 1 + locationOffset . Y ,
847
+ X = Frame . X + pos ,
848
+ Y = Frame . Y + 1 ,
860
849
BarItems = Menus [ index ] ,
861
850
Parent = null
862
851
} ;
863
852
OpenCurrentMenu = _openMenu ;
864
853
OpenCurrentMenu . _previousSubFocused = _openMenu ;
865
854
866
- if ( Application . Top is { } )
855
+ if ( SuperView is { } )
867
856
{
868
- Application . Top . Add ( _openMenu ) ;
857
+ SuperView . Add ( _openMenu ) ;
869
858
// _openMenu.SetRelativeLayout (Application.Screen.Size);
870
859
}
871
860
else
@@ -894,13 +883,11 @@ internal void OpenMenu (int index, int sIndex = -1, MenuBarItem? subMenu = null!
894
883
895
884
if ( ! UseSubMenusSingleFrame )
896
885
{
897
- locationOffset = GetLocationOffset ( ) ;
898
-
899
886
OpenCurrentMenu = new ( )
900
887
{
901
888
Host = this ,
902
- X = last ! . Frame . Left + last . Frame . Width + locationOffset . X ,
903
- Y = last . Frame . Top + locationOffset . Y + last . _currentChild ,
889
+ X = last ! . Frame . Left + last . Frame . Width ,
890
+ Y = last . Frame . Top + last . _currentChild + 1 ,
904
891
BarItems = subMenu ,
905
892
Parent = last
906
893
} ;
@@ -931,7 +918,7 @@ internal void OpenMenu (int index, int sIndex = -1, MenuBarItem? subMenu = null!
931
918
932
919
OpenCurrentMenu . _previousSubFocused = last . _previousSubFocused ;
933
920
_openSubMenu . Add ( OpenCurrentMenu ) ;
934
- Application . Top ? . Add ( OpenCurrentMenu ) ;
921
+ SuperView ? . Add ( OpenCurrentMenu ) ;
935
922
936
923
if ( ! OpenCurrentMenu . IsInitialized )
937
924
{
@@ -1014,7 +1001,7 @@ internal void RemoveAllOpensSubMenus ()
1014
1001
{
1015
1002
foreach ( Menu item in _openSubMenu )
1016
1003
{
1017
- Application . Top ! . Remove ( item ) ;
1004
+ SuperView ? . Remove ( item ) ;
1018
1005
if ( Application . MouseGrabView == item )
1019
1006
{
1020
1007
Application . UngrabMouse ( ) ;
@@ -1263,7 +1250,7 @@ private void RemoveSubMenu (int index, bool ignoreUseSubMenusSingleFrame = false
1263
1250
if ( _openSubMenu is { } )
1264
1251
{
1265
1252
menu = _openSubMenu [ i ] ;
1266
- Application . Top ! . Remove ( menu ) ;
1253
+ SuperView ! . Remove ( menu ) ;
1267
1254
_openSubMenu . Remove ( menu ) ;
1268
1255
1269
1256
if ( Application . MouseGrabView == menu )
0 commit comments