mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-02 09:32:36 +02:00
gtk, gtk2: handle situations when popup menu has been inserted into main menu submenu (remaining part of issue #0014144)
git-svn-id: trunk@20862 -
This commit is contained in:
parent
3a6fe8e7aa
commit
405bc268f5
@ -116,24 +116,30 @@ begin
|
||||
if ParentMenuWidget=nil then
|
||||
RaiseGDBException('TGtkWidgetSet.AttachMenu ParentMenuWidget=nil');
|
||||
|
||||
if GtkWidgetIsA(ParentMenuWidget,GTK_TYPE_MENU_BAR) then begin
|
||||
if GTK_IS_MENU_BAR(ParentMenuWidget) then
|
||||
begin
|
||||
// mainmenu (= a menu bar)
|
||||
ContainerMenu := ParentMenuWidget;
|
||||
gtk_menu_bar_insert(ParentMenuWidget, MenuItem, AMenuItem.MenuVisibleIndex);
|
||||
end
|
||||
else begin
|
||||
// menu item
|
||||
else
|
||||
begin
|
||||
// if it is a menu
|
||||
if GTK_IS_MENU(ParentMenuWidget) then
|
||||
ContainerMenu := ParentMenuWidget
|
||||
else // menu item
|
||||
ContainerMenu := PGtkWidget(gtk_object_get_data(PGtkObject(ParentMenuWidget),
|
||||
'ContainerMenu')); // find the menu container
|
||||
|
||||
// find the menu container
|
||||
ContainerMenu := PGtkWidget(gtk_object_get_data(
|
||||
PGtkObject(ParentMenuWidget),
|
||||
'ContainerMenu'));
|
||||
if ContainerMenu = nil then begin
|
||||
if (GetParentMenu is TPopupMenu) and (Parent.Parent=nil) then begin
|
||||
if ContainerMenu = nil then
|
||||
begin
|
||||
if (GetParentMenu is TPopupMenu) and (Parent.Parent=nil) then
|
||||
begin
|
||||
ContainerMenu := PGtkWidget(GetParentMenu.Handle);
|
||||
gtk_object_set_data(PGtkObject(ContainerMenu), 'ContainerMenu',
|
||||
ContainerMenu);
|
||||
end else begin
|
||||
end else
|
||||
begin
|
||||
ContainerMenu := gtk_menu_new;
|
||||
gtk_object_set_data(PGtkObject(ParentMenuWidget), 'ContainerMenu',
|
||||
ContainerMenu);
|
||||
@ -410,6 +416,7 @@ class procedure TGtkWSPopupMenu.Popup(const APopupMenu: TPopupMenu;
|
||||
var
|
||||
APoint: TPoint;
|
||||
AProc: Pointer;
|
||||
MenuWidget: PGtkWidget;
|
||||
begin
|
||||
ReleaseMouseCapture;
|
||||
APoint.X := X;
|
||||
@ -419,12 +426,13 @@ begin
|
||||
AProc := nil
|
||||
else
|
||||
AProc := @GtkWS_Popup;
|
||||
gtk_menu_popup(PGtkMenu(APopupMenu.Handle),
|
||||
nil,
|
||||
nil,
|
||||
TGtkMenuPositionFunc(AProc),
|
||||
@APoint,
|
||||
0,
|
||||
|
||||
MenuWidget := PGtkWidget(APopupMenu.Handle);
|
||||
// MenuWidget can be either GtkMenu or GtkMenuItem submenu
|
||||
if GTK_IS_MENU_ITEM(MenuWidget) then
|
||||
MenuWidget := gtk_menu_item_get_submenu(PGtkMenuItem(MenuWidget));
|
||||
gtk_menu_popup(PGtkMenu(MenuWidget), nil, nil, TGtkMenuPositionFunc(AProc),
|
||||
@APoint, 0,
|
||||
{$ifdef gtk1}
|
||||
gdk_event_get_time(gtk_get_current_event)
|
||||
{$else}
|
||||
|
@ -175,24 +175,30 @@ begin
|
||||
if ParentMenuWidget=nil then
|
||||
RaiseGDBException('TGtkWidgetSet.AttachMenu ParentMenuWidget=nil');
|
||||
|
||||
if GtkWidgetIsA(ParentMenuWidget,GTK_TYPE_MENU_BAR) then begin
|
||||
if GTK_IS_MENU_BAR(ParentMenuWidget) then
|
||||
begin
|
||||
// mainmenu (= a menu bar)
|
||||
ContainerMenu := ParentMenuWidget;
|
||||
gtk_menu_bar_insert(ParentMenuWidget, MenuItem, AMenuItem.MenuVisibleIndex);
|
||||
end
|
||||
else begin
|
||||
// menu item
|
||||
else
|
||||
begin
|
||||
// if it is a menu
|
||||
if GTK_IS_MENU(ParentMenuWidget) then
|
||||
ContainerMenu := ParentMenuWidget
|
||||
else // menu item
|
||||
ContainerMenu := PGtkWidget(gtk_object_get_data(PGtkObject(ParentMenuWidget),
|
||||
'ContainerMenu')); // find the menu container
|
||||
|
||||
// find the menu container
|
||||
ContainerMenu := PGtkWidget(gtk_object_get_data(
|
||||
PGtkObject(ParentMenuWidget),
|
||||
'ContainerMenu'));
|
||||
if ContainerMenu = nil then begin
|
||||
if (GetParentMenu is TPopupMenu) and (Parent.Parent=nil) then begin
|
||||
if ContainerMenu = nil then
|
||||
begin
|
||||
if (GetParentMenu is TPopupMenu) and (Parent.Parent=nil) then
|
||||
begin
|
||||
ContainerMenu := PGtkWidget(GetParentMenu.Handle);
|
||||
gtk_object_set_data(PGtkObject(ContainerMenu), 'ContainerMenu',
|
||||
ContainerMenu);
|
||||
end else begin
|
||||
end else
|
||||
begin
|
||||
ContainerMenu := gtk_menu_new;
|
||||
gtk_object_set_data(PGtkObject(ParentMenuWidget), 'ContainerMenu',
|
||||
ContainerMenu);
|
||||
|
Loading…
Reference in New Issue
Block a user