mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 22:19:18 +02:00
Gtk3: Create TMainMenu handle (menubar) on demand, needed when TMainMenu is created dynamically at runtime, eg Lazarus IDE.
This commit is contained in:
parent
fd05614958
commit
f35e1cc8ec
@ -8035,6 +8035,7 @@ begin
|
|||||||
FScrollY := 0;
|
FScrollY := 0;
|
||||||
|
|
||||||
FHasPaint := True;
|
FHasPaint := True;
|
||||||
|
FMenuBar := nil;
|
||||||
AForm := TCustomForm(LCLObject);
|
AForm := TCustomForm(LCLObject);
|
||||||
|
|
||||||
if not Assigned(LCLObject.Parent) then
|
if not Assigned(LCLObject.Parent) then
|
||||||
@ -8061,19 +8062,6 @@ begin
|
|||||||
|
|
||||||
FBox := TGtkVBox.new(GTK_ORIENTATION_VERTICAL, 0);
|
FBox := TGtkVBox.new(GTK_ORIENTATION_VERTICAL, 0);
|
||||||
|
|
||||||
//TODO: when menu is added dynamically to the form create FMenuBar
|
|
||||||
{$warning FMenuBar should be created on demand, not here !}
|
|
||||||
if (AForm.Menu <> nil) then
|
|
||||||
begin
|
|
||||||
FMenuBar := TGtkMenuBar.new; // our menubar (needed for main menu)
|
|
||||||
// MenuBar
|
|
||||||
// -> Menu Menu2
|
|
||||||
// Item 1 Item 3
|
|
||||||
// Item 2
|
|
||||||
g_object_set_data(Result,'lclmenubar',GPointer(1));
|
|
||||||
FBox^.pack_start(FMenuBar, False, False, 0);
|
|
||||||
end;
|
|
||||||
|
|
||||||
FScrollWin := PGtkScrolledWindow(TGtkScrolledWindow.new(nil, nil));
|
FScrollWin := PGtkScrolledWindow(TGtkScrolledWindow.new(nil, nil));
|
||||||
g_object_set_data(FScrollWin,'lclscrollingwindow',GPointer(1));
|
g_object_set_data(FScrollWin,'lclscrollingwindow',GPointer(1));
|
||||||
g_object_set_data(PGObject(FScrollWin), 'lclwidget', Self);
|
g_object_set_data(PGObject(FScrollWin), 'lclwidget', Self);
|
||||||
@ -8346,7 +8334,20 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TGtk3Window.GetMenuBar: PGtkMenuBar;
|
function TGtk3Window.GetMenuBar: PGtkMenuBar;
|
||||||
|
var
|
||||||
|
ABox:PGtkBox;
|
||||||
begin
|
begin
|
||||||
|
if not Assigned(FMenuBar) then
|
||||||
|
begin
|
||||||
|
FMenuBar := TGtkMenuBar.new; // our menubar (needed for main menu)
|
||||||
|
// MenuBar
|
||||||
|
// -> Menu Menu2
|
||||||
|
// Item 1 Item 3
|
||||||
|
// Item 2
|
||||||
|
g_object_set_data(Widget,'lclmenubar',GPointer(1));
|
||||||
|
ABox := PGtkBox(PGtkWindow(Widget)^.get_child);
|
||||||
|
ABox^.pack_start(FMenuBar, False, False, 0);
|
||||||
|
end;
|
||||||
Result := FMenuBar;
|
Result := FMenuBar;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user