a104: Re: [a104] Unknown method error A_TrayMenu.Delete() Topic is solved

Report problems with documented functionality
User avatar
Maestr0
Posts: 136
Joined: 05 Dec 2013, 17:43

a104: Re: [a104] Unknown method error A_TrayMenu.Delete()

18 Aug 2019, 08:48

I posted a question here: https://www.autohotkey.com/boards/viewtopic.php?f=82&t=67201
and also asked in v2 on Discord.

It seems there is currently no way to delete the standard tray menu items.

Cap'n'Odin thinks it might be due to this: https://github.com/Lexikos/AutoHotkey_L/commit/0c9151f25bc32f998ec0514053151034d80b6c2b

Why does this code throw an "Unknown method" error with a104?
It's example #3 from "tray menu (customizing)"

Code: Select all

global tray := A_TrayMenu ; For convenience.
tray.delete ; Delete the standard items.
tray.Add("reload", "reload")
Error: Unknown method.

Specifically: delete

Line#
001: tray := A_TrayMenu
---> 002: tray.delete()
003: tray.Add("reload", "reload")
User avatar
Maestr0
Posts: 136
Joined: 05 Dec 2013, 17:43

Re: a104: Re: [a104] Unknown method error A_TrayMenu.Delete()

18 Aug 2019, 09:12

It seems to be limited to the tray menu, as the code below seems to work just fine (only shows "reload 3"):

Code: Select all

MyMenu := MenuCreate()
MyMenu.Add("reload 1", "reload")
MyMenu.Delete()
MyMenu.Add("reload 3", "reload")

#z::MyMenu.Show  ; i.e. press the Win-Z hotkey to show the menu.
joefiesta
Posts: 497
Joined: 24 Jan 2016, 13:54
Location: Pa., USA

Re: a104: Re: [a104] Unknown method error A_TrayMenu.Delete()

18 Aug 2019, 11:38

i don't get any such error. I run 1.1.30.01 AHK under Win 7 Pro 32 bit. But, for what it is worth, it also does not clear the tray menu (even after adding a (necessary?) #persistent to the code).

What are you running?
User avatar
Maestr0
Posts: 136
Joined: 05 Dec 2013, 17:43

Re: a104: Re: [a104] Unknown method error A_TrayMenu.Delete()

18 Aug 2019, 12:27

joefiesta wrote:
18 Aug 2019, 11:38
i don't get any such error. I run 1.1.30.01 AHK under Win 7 Pro 32 bit. But, for what it is worth, it also does not clear the tray menu (even after adding a (necessary?) #persistent to the code).

What are you running?
Hey Joe, thank you for pitching in. Sorry I was unclear, this is a v2 bug report, version a104.

No, #persistent is not necessary in this case.

Oh, and 1.1.30.03 was released as well :)
lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: a104: Re: [a104] Unknown method error A_TrayMenu.Delete()

19 Aug 2019, 03:10

Long story short, the tray menu is created before the Menu object prototype, so the Tray menu has no base object and therefore no predefined methods or properties.

This can be used to "fix" the tray menu (v2.0-a104 only):

Code: Select all

Menu_Prototype := MenuCreate().base
ObjAddRef(&Menu_Prototype)
NumPut("ptr", &Menu_Prototype, &A_TrayMenu + 8 + A_PtrSize)

v1.1.30.03 was released over 4 months ago.
User avatar
Maestr0
Posts: 136
Joined: 05 Dec 2013, 17:43

Re: a104: Re: [a104] Unknown method error A_TrayMenu.Delete()

19 Aug 2019, 04:23

lexikos wrote:
19 Aug 2019, 03:10
Long story short, the tray menu is created before the Menu object prototype, so the Tray menu has no base object and therefore no predefined methods or properties.

This can be used to "fix" the tray menu (v2.0-a104 only):

Code: Select all

Menu_Prototype := MenuCreate().base
ObjAddRef(&Menu_Prototype)
NumPut("ptr", &Menu_Prototype, &A_TrayMenu + 8 + A_PtrSize)
Thanks, that fixed it.
User avatar
Maestr0
Posts: 136
Joined: 05 Dec 2013, 17:43

Re: a104: Re: [a104] Unknown method error A_TrayMenu.Delete()

28 Sep 2019, 06:24

lexikos wrote:
24 Sep 2019, 02:25
Fixed in v2.0-a105.
awesome, thanks for the update.
lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: a104: Re: [a104] Unknown method error A_TrayMenu.Delete()

28 Sep 2019, 18:24

This bug-fix introduced a new bug, which can be worked around as follows:

Code: Select all

if !ObjGetBase(A_TrayMenu.base)
	ObjSetBase(A_TrayMenu.base, Object.Prototype)

Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 24 guests