{"action":"created","issue":{"url":"https://api.github.com/repos/gotk3/gotk3-examples/issues/12","repository_url":"https://api.github.com/repos/gotk3/gotk3-examples","labels_url":"https://api.github.com/repos/gotk3/gotk3-examples/issues/12/labels{/name}","comments_url":"https://api.github.com/repos/gotk3/gotk3-examples/issues/12/comments","events_url":"https://api.github.com/repos/gotk3/gotk3-examples/issues/12/events","html_url":"https://github.com/gotk3/gotk3-examples/issues/12","id":384079833,"node_id":"MDU6SXNzdWUzODQwNzk4MzM=","number":12,"title":"Connect function called during execution","user":{"login":"BorisLeMeec","id":16005667,"node_id":"MDQ6VXNlcjE2MDA1NjY3","avatar_url":"https://avatars3.githubusercontent.com/u/16005667?v=4","gravatar_id":"","url":"https://api.github.com/users/BorisLeMeec","html_url":"https://github.com/BorisLeMeec","followers_url":"https://api.github.com/users/BorisLeMeec/followers","following_url":"https://api.github.com/users/BorisLeMeec/following{/other_user}","gists_url":"https://api.github.com/users/BorisLeMeec/gists{/gist_id}","starred_url":"https://api.github.com/users/BorisLeMeec/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/BorisLeMeec/subscriptions","organizations_url":"https://api.github.com/users/BorisLeMeec/orgs","repos_url":"https://api.github.com/users/BorisLeMeec/repos","events_url":"https://api.github.com/users/BorisLeMeec/events{/privacy}","received_events_url":"https://api.github.com/users/BorisLeMeec/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-11-25T13:38:37Z","updated_at":"2018-11-25T13:44:15Z","closed_at":null,"author_association":"NONE","body":"Hi,\r\n\r\nFirstly, thank you for your amazing work !\r\n\r\nBut I have some questions regarding behavior of buttons, I'm not used to Gtk either.\r\n\r\nWhen I try to connect a button to a function of mine for event \"clicked\" this function is called directly during execution of program, and not when the user click on a button.\r\nIn my case it is kind of an infinite loop, so the window es not even displayed, do you know where I am wrong ? :\r\n\r\n```\r\nfunc main() {\r\n\tgtk.Init(nil)\r\n\r\n\twin, err := gtk.WindowNew(gtk.WINDOW_TOPLEVEL)\r\n\tif err != nil {\r\n\t\tlog.Fatal(\"Unable to create window:\", err)\r\n\t}\r\n\twin.SetTitle(\"Add/Remove Widgets Example\")\r\n\twin.Connect(\"destroy\", func() {\r\n\t\tgtk.MainQuit()\r\n\t})\r\n\r\n\twin.Add(windowWidget())\r\n\twin.ShowAll()\r\n\r\n\tgtk.Main()\r\n}\r\n```\r\n\r\n```\r\nfunc windowWidget() *gtk.Widget {\r\n\tgrid, err := gtk.GridNew()\r\n\tif err != nil {\r\n\t\tlog.Fatal(\"Unable to create grid:\", err)\r\n\t}\r\n\tgrid.SetOrientation(gtk.ORIENTATION_VERTICAL)\r\n\r\n\r\n\tinsertBtn, err := gtk.ButtonNewWithLabel(\"HelloWorld\")\r\n\tif err != nil {\r\n\t\tlog.Fatal(\"Unable to create button:\", err)\r\n\t}\r\n\tinsertBtn.Connect(\"clicked\", func() {})\r\n\tinsertBtn.ConnectAfter(\"clicked\", getZoneScreen())\r\n\r\n\tgrid.Attach(insertBtn, 0, 1, 1, 1)\r\n\treturn &grid.Container.Widget\r\n}\r\n```\r\n```\r\nfunc getZoneScreen() (i interface{}) {\r\n\tfor true{\r\n\t\tfmt.Println(robotgo.GetMousePos())\r\n\t}\r\n\treturn\r\n}```"},"comment":{"url":"https://api.github.com/repos/gotk3/gotk3-examples/issues/comments/441441474","html_url":"https://github.com/gotk3/gotk3-examples/issues/12#issuecomment-441441474","issue_url":"https://api.github.com/repos/gotk3/gotk3-examples/issues/12","id":441441474,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0MTQ0MTQ3NA==","user":{"login":"Bios-Marcel","id":19377618,"node_id":"MDQ6VXNlcjE5Mzc3NjE4","avatar_url":"https://avatars3.githubusercontent.com/u/19377618?v=4","gravatar_id":"","url":"https://api.github.com/users/Bios-Marcel","html_url":"https://github.com/Bios-Marcel","followers_url":"https://api.github.com/users/Bios-Marcel/followers","following_url":"https://api.github.com/users/Bios-Marcel/following{/other_user}","gists_url":"https://api.github.com/users/Bios-Marcel/gists{/gist_id}","starred_url":"https://api.github.com/users/Bios-Marcel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Bios-Marcel/subscriptions","organizations_url":"https://api.github.com/users/Bios-Marcel/orgs","repos_url":"https://api.github.com/users/Bios-Marcel/repos","events_url":"https://api.github.com/users/Bios-Marcel/events{/privacy}","received_events_url":"https://api.github.com/users/Bios-Marcel/received_events","type":"User","site_admin":false},"created_at":"2018-11-25T13:44:15Z","updated_at":"2018-11-25T13:44:15Z","author_association":"CONTRIBUTOR","body":"You have made a mistake, you aren't supposed to call the method `getZoneScreen`, instead you are supposed to pass it.\r\n\r\nHere is how it should have been done:\r\n\r\n```Go\r\nfunc windowWidget() *gtk.Widget {\r\n\tgrid, err := gtk.GridNew()\r\n\tif err != nil {\r\n\t\tlog.Fatal(\"Unable to create grid:\", err)\r\n\t}\r\n\tgrid.SetOrientation(gtk.ORIENTATION_VERTICAL)\r\n\r\n\tinsertBtn, err := gtk.ButtonNewWithLabel(\"HelloWorld\")\r\n\tif err != nil {\r\n\t\tlog.Fatal(\"Unable to create button:\", err)\r\n\t}\r\n\tinsertBtn.Connect(\"clicked\", func() {})\r\n\tinsertBtn.ConnectAfter(\"clicked\", getZoneScreen)\r\n\r\n\tgrid.Attach(insertBtn, 0, 1, 1, 1)\r\n\treturn &grid.Container.Widget\r\n}\r\n\r\nfunc getZoneScreen() {\r\n\tfor true {\r\n\t\tfmt.Println(\"Replacement for your call\")\r\n\t}\r\n}\r\n```"}}
{"actor":{"display_login":"Bios-Marcel"}}