MenuBar items do not execute callback when clicked.
Issue #20
closed
Working AHK code:
MyGui := Gui(, "KEYSHARP TESTS")
MyMenuBar := MenuBar()
MyMenuBar.Add("File", FileCallBack)
MyMenuBar.Add("Edit", EditCallback)
MyGui.MenuBar := MyMenuBar
MyEdit := MyGui.Add("Edit", "w400 h400")
MyGui.Show()
FileCallback(*) {
MsgBox("Clicked File")
}
EditCallback(*) {
MsgBox("Clicked Edit")
}
Keysharp - Menubar displays and can be clicked, but callbacks do not execute.
MyGui := Gui(, "KEYSHARP TESTS")
MyMenuBar := MenuBar()
MyMenuBar.Add("File", "FileCallBack")
MyMenuBar.Add("Edit", "EditCallback")
MyGui.MenuBar := MyMenuBar
MyEdit := MyGui.Add("Edit", "w400 h400")
MyGui.Show()
FileCallback() {
MsgBox("Clicked File")
}
EditCallback() {
MsgBox("Clicked Edit")
}
Comments (5)
-
repo owner -
repo owner FileMenu := Menu() FileMenu.Add("Script Icon", "MenuHandler") FileMenu.Add("Suspend Icon", "MenuHandler") FileMenu.Add("Pause Icon", "MenuHandler") FileMenu.SetIcon("Script Icon", A_AhkPath, 2) ; 2nd icon group from the file FileMenu.SetIcon("Suspend Icon", A_AhkPath, -206) ; icon with resource ID 206 FileMenu.SetIcon("Pause Icon", A_AhkPath, -207) ; icon with resource ID 207 EditMenu := Menu() EditMenu.Add("Cut", "MenuHandler") EditMenu.Add("Copy", "MenuHandler") EditMenu.Add("Paste", "MenuHandler") Submenu1 := Menu() Submenu1.Add("Item A", "MenuHandler") Submenu1.Add("Item B", "MenuHandler") EditMenu.Add("A useless submenu", Submenu1) MyMenuBar := MenuBar() MyMenuBar.Add("&File", FileMenu) MyMenuBar.Add("&Edit", EditMenu) MyGui := Gui() MyGui.MenuBar := MyMenuBar MyGui.Add("Edit", "w200 h200") btn := MyGui.Add("Button",, "Exit This Example") btn.OnEvent("Click", "MenuHandler") MyGui.Show MenuHandler(*) { MsgBox("You clicked an item.") ; For this example, the menu items don't do anything. }
-
reporter Following works, with the caveat that icons do not display, which is a separate issue:
FileMenu := Menu() FileMenu.Add("Script Icon", "MenuHandler") FileMenu.Add("Suspend Icon", "MenuHandler") FileMenu.Add("Pause Icon", "MenuHandler") FileMenu.SetIcon("Script Icon", A_AhkPath, 2) ; 2nd icon group from the file FileMenu.SetIcon("Suspend Icon", A_AhkPath, -206) ; icon with resource ID 206 FileMenu.SetIcon("Pause Icon", A_AhkPath, -207) ; icon with resource ID 207 EditMenu := Menu() EditMenu.Add("Cut", "MenuHandler") EditMenu.Add("Copy", "MenuHandler") EditMenu.Add("Paste", "MenuHandler") Submenu1 := Menu() Submenu1.Add("Item A", "MenuHandler") Submenu1.Add("Item B", "MenuHandler") EditMenu.Add("A useless submenu", Submenu1) MyMenuBar := MenuBar() MyMenuBar.Add("&File", FileMenu) MyMenuBar.Add("&Edit", EditMenu) MyGui := Gui() MyGui.MenuBar := MyMenuBar MyGui.Add("Edit", "w200 h200") btn := MyGui.Add("Button",, "Exit This Example") btn.OnEvent("Click", "MyGui_Close") MyGui.Show() MenuHandler() { MsgBox("You clicked an item.") ; For this example, the menu items don't do anything. } MyGui_Close() { ExitApp() }
Please mark resolved and close. Thanks!
-
repo owner - changed status to resolved
-
repo owner - changed status to closed
- Log in to comment
Fix committed, please test.