dontpanic92 / wxGo

Golang wxWidgets Wrapper
Other
403 stars 51 forks source link

SetVeto in EVT_CLOSE_WINDOW? #65

Closed undeadindustries closed 6 years ago

undeadindustries commented 6 years ago

How would I set veto in a Bind?

wx.Bind(w, wx.EVT_CLOSE_WINDOW, func(e wx.Event) {
        e.SetVeto(false) //????
    }, w.GetId())

Thanks!

Asday commented 6 years ago

I believe you're after .Veto(), defined here.

undeadindustries commented 6 years ago

I tried that before I posted here. It doesn't seem to think Veto is part of "e" ...

If you copy and my paste that code into a quick app, to see if it does it for you?

Wish I could post an image of it here.

Thank you!

Asday commented 6 years ago

screenshot_20180817-205443

This is what I'm going off. That, and the official wx docs list .Veto() as the function to use on wxCloseEvent.

If you could put together a small repository demonstrating your issue, I'll check it out when I wake up. At least then I'll be able to see the error codes.

dontpanic92 commented 6 years ago

I think firstly, you should convert the event to CloseEvent:

closeEvent := wx.ToCloseEvent(e)

CloseEvent has a method named Veto:

closeEvent.Veto()
undeadindustries commented 6 years ago

dontpanic92, that worked!

However, when I have something bound to my close event, the window doesn't close. I'll update this soon if I don't sort it out. If not, I'll close this. Thank you!

undeadindustries commented 6 years ago

I forgot to add Destroy() at the end. all set. Thanks again!!