diamondburned/gotk4

Cast glib.Object to another type

pekim opened this issue · 2 comments

pekim commented
	builder := gtk.NewBuilderFromString("...", -1)
	object:= builder.GetObject("some-object-of-interest")

I might know that the retrieved glib.Object is a button or maybe a menu, but I can't find a means to cast it to a gtk.Button or a gio.Menu. There are "wrap" functions that might do this, but they are not exported.

Is there some API for doing this that I've overlooked, or does it simply not exist yet?

It should be builder.GetObject("some-object-of-interest").Cast().(*gtk.Button).

I saw Object's Cast method, but didn't appreciate how to use it. And I couldn't find any example of it being used.

It's exactly what I was looking for. Thank you.