Recent

Author Topic: TrayIcon MenuItem Caption not updated  (Read 3407 times)

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
TrayIcon MenuItem Caption not updated
« on: October 04, 2017, 03:52:53 am »
Hi, not sure if this should be posted under LCL or MacOSX. But here goes-

Under OSX (but not Linux or Windows) a MenuItem belonging to a PopupMenu associated with a TrayIcon cannot be updated at run time. Easy to reproduce -

On a clean form, drop a TrayIcon, a PopupMenu and, for logging, a TMemo. Set the trayicon's popupmenu property to the popupmenu, add a menu item to the popupmenu. Show the trayicon (with OnShow or a button) and add a button that does this -

Code: Pascal  [Select][+][-]
  1. procedure TForm1.Button1.Click(Sender: TObject);
  2. begin
  3.     MenuItem1.Caption := 'I changed this';
  4.     Memo1.Append(MenuItem1.caption);
  5. end;

You will see what you expect in the memo, "I changed this" but click the TrayIcon and the menu text displayed is still "MenuItem1". The caption itself is being changed but apparently noone is telling the PopupMenu. Changing caption at design time works perfectly.

This all works fine under Windows and Linux. Is there any reason why I should not log it as a bug ? Under Lazarus Packages ?

Lazarus 1.8RC4, Mac OSX Sierra.

David


Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Hansaplast

  • Hero Member
  • *****
  • Posts: 674
  • Tweaking4All.com
    • Tweaking4All
Re: TrayIcon MenuItem Caption not updated
« Reply #1 on: October 04, 2017, 05:32:09 pm »
I ran into a similar problem, and used internalupdate() for that, which worked in my case:


Code: Pascal  [Select][+][-]
  1. TrayIcon.InternalUpdate;


In my case I restructured the menu on the fly, which didn't take, but after calling the InternalUpdate function, the menu did get updated.


Hope this helps.

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
Re: TrayIcon MenuItem Caption not updated
« Reply #2 on: October 05, 2017, 03:44:55 am »
yep, you are right Hans, thanks. I was looking for something to do that in the PopUpMenu itself. But clearly, a TrayIcon issue.

I'll put a note on the wiki.

Still sounds like a bug to me, think I'll also log it on the bug tracker.

Thanks
David
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
Re: TrayIcon MenuItem Caption not updated
« Reply #3 on: October 06, 2017, 11:10:04 am »
Logged - issue 32516
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

Hansaplast

  • Hero Member
  • *****
  • Posts: 674
  • Tweaking4All.com
    • Tweaking4All
Re: TrayIcon MenuItem Caption not updated
« Reply #4 on: October 07, 2017, 10:48:18 pm »
Hi David,


glad to hear that worked for you, and thanks for creating a bug report.
I guess I could have thought of that myself at the time.  :-[

 

TinyPortal © 2005-2018