Recent

Author Topic: [SOLVED] Help menu duplicated  (Read 3410 times)

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
[SOLVED] Help menu duplicated
« on: October 22, 2019, 01:45:47 pm »
When using ShowMessage() or CreateMessageDialog() in any of the FormCreate, FormActivate, or FormShow event handlers, I end up with two Help menus on the Menu bar. The first one has the Search and Help entries, the second one has the Help entry only.

I've worked around it by setting up a TTimer (500ms) to display the message after the main form has been made visible. Is there a better way? I suspect I must be  missing something obvious :)
« Last Edit: December 31, 2019, 01:53:59 am by trev »

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Help menu duplicated
« Reply #1 on: October 22, 2019, 03:53:08 pm »
When using ShowMessage() or CreateMessageDialog() in any of the FormCreate, FormActivate, or FormShow event handlers, I end up with two Help menus on the Menu bar. The first one has the Search and Help entries, the second one has the Help entry only.

I've worked around it by setting up a TTimer (500ms) to display the message after the main form has been made visible. Is there a better way? I suspect I must be  missing something obvious :)
Without seeing compilable code that produces this duplication how can anyone say what might be better?

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: Help menu duplicated
« Reply #2 on: October 24, 2019, 05:52:45 am »
Any trivial example code will trigger this issue and I thought someone may have come across it before, but fair enough, I've attached a 3Kb zip file of a trivial compilable app with a blank form apart from a TMainMenu control. The unit (as below) has just enough code to provide a working Apple Help Book menu item.

Code: Pascal  [Select][+][-]
  1. unit unit1;
  2. {$mode objfpc}{$H+}
  3. interface
  4. uses
  5.   Classes, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls,
  6.   Menus, LCLIntf, MacOSAll;
  7. type
  8.   { TForm1 }
  9.   TForm1 = class(TForm)
  10.     MainMenu1: TMainMenu;
  11.     MenuItem_AppHelp: TMenuItem;
  12.     MenuItem_Help: TMenuItem;
  13.     procedure FormShow(Sender: TObject);
  14.     procedure MenuItem_AppHelpClick(Sender: TObject);
  15.   private
  16.   public
  17.   end;
  18. var
  19.   Form1: TForm1;
  20. implementation
  21. {$R *.lfm}
  22. { TForm1 }
  23.  
  24. function GetResourcesPath(): string;
  25. var
  26.   pathRef: CFURLRef;
  27.   pathCFStr: CFStringRef;
  28.   pathStr: shortstring;
  29. begin
  30.   pathRef := CFBundleCopyBundleURL(CFBundleGetMainBundle());
  31.   pathCFStr := CFURLCopyFileSystemPath(pathRef, kCFURLPOSIXPathStyle);
  32.   CFStringGetPascalString(pathCFStr, @pathStr, 255, CFStringGetSystemEncoding());
  33.   CFRelease(pathRef);
  34.   CFRelease(pathCFStr);
  35.   Result := pathStr + '/Contents/Resources/';
  36. end;
  37.  
  38. procedure TForm1.MenuItem_AppHelpClick(Sender: TObject);
  39. var
  40.   helpPath: String;
  41. begin
  42.   helpPath := GetResourcesPath + 'MyApp.help';
  43.   OpenDocument(helpPath );
  44. end;
  45.  
  46. procedure TForm1.FormShow(Sender: TObject);
  47. begin
  48.   ShowMessage('Help Help');
  49. end;
  50.  
  51. end.
  52.  

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: Help menu duplicated
« Reply #3 on: October 24, 2019, 10:04:08 am »
Apologies, I had failed to register that this was a Cocoa-related issue. I am not able to help with that.

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: Help menu duplicated
« Reply #4 on: October 24, 2019, 10:44:10 am »
No worries - there's an example here now for the next person :)

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: Help menu duplicated
« Reply #5 on: December 03, 2019, 07:07:22 pm »
I ran your app on current fixes and current trunk. In each case the ShowMessage dialog pops up on FormShow. The Help menu is not displayed until the dialog is dismissed. After that the Help menu is displayed with two entries: Search and Help.

Maybe try the fixes branch.
« Last Edit: December 03, 2019, 07:22:27 pm by VTwin »
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 12.1: Lazarus 2.2.6 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.6 (64 bit on VBox)

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: Help menu duplicated
« Reply #6 on: December 04, 2019, 01:44:01 am »
I'll update my trunk and retry.

Curiously, the same behaviour is exhibited under Delphi 10.2.

VTwin

  • Hero Member
  • *****
  • Posts: 1215
  • Former Turbo Pascal 3 user
Re: Help menu duplicated
« Reply #7 on: December 04, 2019, 02:38:30 am »
I'll update my trunk and retry.

Curiously, the same behaviour is exhibited under Delphi 10.2.

Have you tried the fixes branch instead of trunk? I only use trunk to test bug fixes, it is generally less stable. No idea about Delphi.
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.2
macOS 12.1: Lazarus 2.2.6 (64 bit Cocoa M1)
Ubuntu 18.04.3: Lazarus 2.2.6 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.2.6 (64 bit on VBox)

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: Help menu duplicated
« Reply #8 on: December 04, 2019, 07:50:19 am »
No, I've not tried a fixes branch as Dmitry had fixed various Cocoa blemishes for me which were only in trunk.

As for trunk's stability, I've had excellent luck thus far which is a testament to the committers.

Thanks for your suggestions!

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2020
  • Former Delphi 1-7, 10.2 user
Re: Help menu duplicated
« Reply #9 on: December 31, 2019, 01:53:23 am »
This is now fixed -- it no longer occurs with Lazarus 2.1 r42644 :)

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
Re: Help menu duplicated
« Reply #10 on: December 31, 2019, 04:49:20 am »
This is now fixed -- it no longer occurs with Lazarus 2.1 r42644 :)
it is also now in fixes branch as well.

 

TinyPortal © 2005-2018