Official help file, what is the cause of the error? Topic is solved

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
cgx5871
Posts: 319
Joined: 26 Jul 2018, 14:02

Official help file, what is the cause of the error?

20 Feb 2024, 16:31

Error: Invalid callback function.

Code: Select all

#Requires Autohotkey v2
#SingleInstance

myGui := Gui()
myGui.Add("Button", "", "&OK").OnEvent("ContextMenu", Gui_ContextMenu)
myGui.show
Gui_ContextMenu(GuiObj, GuiCtrlObj, Item, IsRightClick, X, Y){
  MsgBox GuiObj.Name
}
image.png
image.png (20.02 KiB) Viewed 101 times
User avatar
boiler
Posts: 17346
Joined: 21 Dec 2014, 02:44

Re: Official help file, what is the cause of the error?  Topic is solved

20 Feb 2024, 18:15

That's the parameter list for a GUI object ContextMenu event callback function. You have a GUI control object Context Menu event callback function, whose parameter list is:
Ctrl_ContextMenu(GuiCtrlObj, Item, IsRightClick, X, Y)


What you did is as if you applied the event to the GUI object:

Code: Select all

#Requires Autohotkey v2
#SingleInstance

myGui := Gui()
myGui.OnEvent("ContextMenu", Gui_ContextMenu)
myGui.Add("Button", "", "&OK")
myGui.show
Gui_ContextMenu(GuiObj, GuiCtrlObj, Item, IsRightClick, X, Y){
  MsgBox GuiObj.Name
}

Return to “Ask for Help (v2)”

Who is online

Users browsing this forum: Draken, teadrinker and 23 guests