* * *

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

dbannon

  • Jr. Member
  • **
  • Posts: 98
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 1.8, Linux (and reluctantly Win10, OSX)

Hansaplast

  • Sr. Member
  • ****
  • Posts: 288
  • 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

  • Jr. Member
  • **
  • Posts: 98
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 1.8, Linux (and reluctantly Win10, OSX)

dbannon

  • Jr. Member
  • **
  • Posts: 98
Re: TrayIcon MenuItem Caption not updated
« Reply #3 on: October 06, 2017, 11:10:04 am »
Logged - issue 32516
Lazarus 1.8, Linux (and reluctantly Win10, OSX)

Hansaplast

  • Sr. Member
  • ****
  • Posts: 288
  • 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.  :-[

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus