// Package gtk was automatically generated by github.com/bnema/puregotk DO NOT EDIT package gtk import ( "structs" "unsafe" "github.com/ebitengine/purego" "github.com/bnema/puregotk/pkg/core" "github.com/bnema/puregotk/v4/glib" "github.com/bnema/puregotk/v4/gobject" "github.com/bnema/puregotk/v4/gobject/types" ) type EventControllerFocusClass struct { _ structs.HostLayout } func (x *EventControllerFocusClass) GoPointer() uintptr { return uintptr(unsafe.Pointer(x)) } // Tracks keyboard focus. // // The event controller offers [signal@Gtk.EventControllerFocus::enter] // and [signal@Gtk.EventControllerFocus::leave] signals, as well as // [property@Gtk.EventControllerFocus:is-focus] and // [property@Gtk.EventControllerFocus:contains-focus] properties // which are updated to reflect focus changes inside the widget hierarchy // that is rooted at the controllers widget. type EventControllerFocus struct { EventController } var xEventControllerFocusGLibType func() types.GType func EventControllerFocusGLibType() types.GType { return xEventControllerFocusGLibType() } func EventControllerFocusNewFromInternalPtr(ptr uintptr) *EventControllerFocus { cls := &EventControllerFocus{} cls.Ptr = ptr return cls } var xNewEventControllerFocus func() uintptr // Creates a new event controller that will handle focus events. func NewEventControllerFocus() *EventControllerFocus { var cls *EventControllerFocus cret := xNewEventControllerFocus() if cret == 0 { return nil } cls = &EventControllerFocus{} cls.Ptr = cret return cls } var xEventControllerFocusContainsFocus func(uintptr) bool // Returns %TRUE if focus is within @self or one of its children. func (x *EventControllerFocus) ContainsFocus() bool { cret := xEventControllerFocusContainsFocus(x.GoPointer()) return cret } var xEventControllerFocusIsFocus func(uintptr) bool // Returns %TRUE if focus is within @self, but not one of its children. func (x *EventControllerFocus) IsFocus() bool { cret := xEventControllerFocusIsFocus(x.GoPointer()) return cret } func (c *EventControllerFocus) GoPointer() uintptr { if c == nil { return 0 } return c.Ptr } func (c *EventControllerFocus) SetGoPointer(ptr uintptr) { c.Ptr = ptr } // GetPropertyContainsFocus gets the "contains-focus" property. // %TRUE if focus is contained in the controllers widget. // // See [property@Gtk.EventControllerFocus:is-focus] for whether // the focus is in the widget itself or inside a descendent. // // When handling focus events, this property is updated // before [signal@Gtk.EventControllerFocus::enter] or // [signal@Gtk.EventControllerFocus::leave] are emitted. func (x *EventControllerFocus) GetPropertyContainsFocus() bool { var v gobject.Value x.GetProperty("contains-focus", &v) return v.GetBoolean() } // GetPropertyIsFocus gets the "is-focus" property. // %TRUE if focus is in the controllers widget itself, // as opposed to in a descendent widget. // // See also [property@Gtk.EventControllerFocus:contains-focus]. // // When handling focus events, this property is updated // before [signal@Gtk.EventControllerFocus::enter] or // [signal@Gtk.EventControllerFocus::leave] are emitted. func (x *EventControllerFocus) GetPropertyIsFocus() bool { var v gobject.Value x.GetProperty("is-focus", &v) return v.GetBoolean() } // Emitted whenever the focus enters into the widget or one // of its descendents. // // Note that this means you may not get an ::enter signal // even though the widget becomes the focus location, in // certain cases (such as when the focus moves from a descendent // of the widget to the widget itself). If you are interested // in these cases, you can monitor the // [property@Gtk.EventControllerFocus:is-focus] // property for changes. func (x *EventControllerFocus) ConnectEnter(cb *func(EventControllerFocus)) uint { cbPtr := uintptr(unsafe.Pointer(cb)) if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { handlerID := gobject.SignalConnect(x.GoPointer(), "enter", cbRefPtr) glib.SaveHandlerMapping(handlerID, cbPtr) return handlerID } fcb := func(clsPtr uintptr) { fa := EventControllerFocus{} fa.Ptr = clsPtr cbFn := *cb cbFn(fa) } cbRefPtr := purego.NewCallback(fcb) glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb) handlerID := gobject.SignalConnect(x.GoPointer(), "enter", cbRefPtr) glib.SaveHandlerMapping(handlerID, cbPtr) return handlerID } // Emitted whenever the focus leaves the widget hierarchy // that is rooted at the widget that the controller is attached to. // // Note that this means you may not get a ::leave signal // even though the focus moves away from the widget, in // certain cases (such as when the focus moves from the widget // to a descendent). If you are interested in these cases, you // can monitor the [property@Gtk.EventControllerFocus:is-focus] // property for changes. func (x *EventControllerFocus) ConnectLeave(cb *func(EventControllerFocus)) uint { cbPtr := uintptr(unsafe.Pointer(cb)) if cbRefPtr, ok := glib.GetCallback(cbPtr); ok { handlerID := gobject.SignalConnect(x.GoPointer(), "leave", cbRefPtr) glib.SaveHandlerMapping(handlerID, cbPtr) return handlerID } fcb := func(clsPtr uintptr) { fa := EventControllerFocus{} fa.Ptr = clsPtr cbFn := *cb cbFn(fa) } cbRefPtr := purego.NewCallback(fcb) glib.SaveCallbackWithClosure(cbPtr, cbRefPtr, cb) handlerID := gobject.SignalConnect(x.GoPointer(), "leave", cbRefPtr) glib.SaveHandlerMapping(handlerID, cbPtr) return handlerID } func init() { core.SetPackageName("GTK", "gtk4") core.SetSharedLibraries("GTK", []string{"libgtk-4.so.1"}) var libs []uintptr for _, libPath := range core.GetPaths("GTK") { lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL) if err != nil { panic(err) } libs = append(libs, lib) } core.PuregoSafeRegister(&xEventControllerFocusGLibType, libs, "gtk_event_controller_focus_get_type") core.PuregoSafeRegister(&xNewEventControllerFocus, libs, "gtk_event_controller_focus_new") core.PuregoSafeRegister(&xEventControllerFocusContainsFocus, libs, "gtk_event_controller_focus_contains_focus") core.PuregoSafeRegister(&xEventControllerFocusIsFocus, libs, "gtk_event_controller_focus_is_focus") }