gform icon indicating copy to clipboard operation
gform copied to clipboard

Bind() doesn't work?

Open jcsmnt0 opened this issue 13 years ago • 4 comments

I can't get the Bind() method to work at all. All of your examples build and run for me, but button clicks or anything else that uses Bind() doesn't work. Even trivially simple code like this doesn't work:

func onclick(arg *gform.EventArg) {
    println("hello")
}

func main() {
    gform.Init()

    mainWindow := gform.NewForm(nil)

    btn := gform.NewPushButton(mainWindow)
    btn.OnLBDown().Bind(onclick)

    mainWindow.Show()

    gform.RunMainLoop()
}

The code builds and runs and the window appears with the button, but nothing happens when I click the button. Am I doing something wrong? I'm running on Windows 7 64-bit, using go1.

jcsmnt0 avatar May 21 '12 01:05 jcsmnt0

I don't have x64 machine in hand, but I think it's the root cause, because I didn't take special action to keep all the windows APIs gform used to be compatible with x64.

AllenDang avatar May 23 '12 11:05 AllenDang

I think this is NOT bug. I guess that your Windows 7 CPU is NOT amd64.notice that 64-bit dont mean amd64 :) try this: set goarch=386 and go build again should fixed your issue,or you should download GO1.01 386 version,NOT GO1.01 amd64

axgle avatar May 29 '12 17:05 axgle

@axgle: No, my CPU is an Intel Core i7 which definitely does run on the amd64 architecture (also known as x86-64 or x64, see: http://software.intel.com/en-us/articles/all-about-64-bits/#IDAJLUBC). If it wasn't, I'm pretty sure it wouldn't be able to execute any of the files that the amd64 Go compiler outputs. The problem seems to be that gform doesn't fully support the 64-bit Windows API.

@AllenDang: Thanks for responding - are there any plans for 64-bit support? I don't know enough about the Windows API to help with the code, but I'd be happy to help test it on a 64-bit machine if that would help you at all. The Bind method does work fine for me when I build the program as a 32-bit executable, but I've found that the speed gains from using 64-bit vs. 32-bit in Go are sometimes actually pretty noticeable, so I'm reluctant to switch over to using the 32-bit compiler. Either way, thanks for making an awesome package!

jcsmnt0 avatar May 30 '12 00:05 jcsmnt0

I have the same problem (on windows 7 64bits). In fact, some events are not triggered. But mainWindow.OnLBDown().Bind(onclick) works. I think the button blocks mouse events on it. I tried to create my own button with your API, but it is tricky for a poor result.

milak avatar Sep 24 '12 21:09 milak