Recent

Author Topic: [SOLVED] Popup Menu on Modal Window in OS X  (Read 3018 times)

agorka

  • New Member
  • *
  • Posts: 25
[SOLVED] Popup Menu on Modal Window in OS X
« on: May 21, 2016, 10:11:15 pm »
Hello!

Here's another problem with Modal window on OS X I get.
When I show form with ShowModal, and it tries to show PopupMenu, it get's under the form itself, so you don't see the menu, and all visible controls get locked. You can see the PopupMenu on a different desktop if you switch OS X desktop with three finger swipe.
If I show the form with Show, PopupMenu appears without any problem.
Here's the test app (just add two buttons to the form and paste the source):
Code: Pascal  [Select][+][-]
  1. unit unit2;
  2.  
  3. {$mode objfpc}{$H+}
  4.  
  5. interface
  6.  
  7. uses
  8.   Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
  9.   Menus;
  10.  
  11. type
  12.  
  13.   { TForm1 }
  14.  
  15.   TForm1 = class(TForm)
  16.     Button1: TButton;
  17.     Button2: TButton;
  18.     procedure Button1Click(Sender: TObject);
  19.     procedure Button2Click(Sender: TObject);
  20.   private
  21.     { private declarations }
  22.   public
  23.     { public declarations }
  24.   end;
  25.  
  26. var
  27.   Form1: TForm1;
  28.  
  29. implementation
  30.  
  31. {$R *.lfm}
  32.  
  33. { TForm1 }
  34.  
  35. procedure TForm1.Button1Click(Sender: TObject);
  36. var PopupMenu1 : TPopupMenu;
  37. begin
  38. PopupMenu1:=TPopupMenu.Create(Self);
  39. PopupMenu1.Items.Add(TMenuItem.Create(PopupMenu));
  40. PopupMenu1.Items[0].Caption:='Test 1';
  41. PopupMenu1.PopUp;
  42. end;
  43.  
  44. procedure TForm1.Button2Click(Sender: TObject);
  45. var F : TForm;
  46. begin
  47. F:=TForm.CreateNew(Self);
  48. F.InsertControl(TButton.Create(F));
  49. TButton(F.Controls[0]).Caption:='Test popup';
  50. TButton(F.Controls[0]).OnClick:=@Button1Click;
  51. F.ShowModal;
  52. end;
  53.  
  54. end.
  55.  

Any ideas how to fix that? Is it a bug?
« Last Edit: May 22, 2016, 09:36:12 pm by agorka »

agorka

  • New Member
  • *
  • Posts: 25
Re: Popup Menu on Modal Window in OS X
« Reply #1 on: May 22, 2016, 10:06:44 am »
I also noticed that if I show window with Show, but set PopupMode to PopupExplicit, I get the same problem - Popup menus are hidden behind the window and not accessible.

agorka

  • New Member
  • *
  • Posts: 25
Re: Popup Menu on Modal Window in OS X
« Reply #2 on: May 22, 2016, 09:35:12 pm »
I found the solution!
This problem is caused by this bug
http://bugs.freepascal.org/view.php?id=29694
And the solution seem to work!

So, the problem is SOLVED!

jwdietrich

  • Hero Member
  • *****
  • Posts: 1257
    • formatio reticularis
Re: [SOLVED] Popup Menu on Modal Window in OS X
« Reply #3 on: May 22, 2016, 10:24:25 pm »
Thanks for providing the solution.
function GetRandomNumber: integer; // xkcd.com
begin
  GetRandomNumber := 4; // chosen by fair dice roll. Guaranteed to be random.
end;

http://www.formatio-reticularis.de

Lazarus 4.0.0 | FPC 3.2.2 | PPC, Intel, ARM | macOS, Windows, Linux

 

TinyPortal © 2005-2018