// Conversion function func newEventFromNative(obj unsafe.Pointer) interface{} { // Cast to EventAny to extract type and send var var window *Window = nil ceventAny := (*C.GdkEventAny)(obj) t := int(ceventAny._type) if win, err := gobject.ConvertToGo(unsafe.Pointer(ceventAny.window)); err == nil { window = win.(*Window) } se := ceventAny.send_event send := gobject.GoBool(unsafe.Pointer(&se)) // Create new EventAny Struct eventAny := EventAny{t, window, send} // test specific events switch t { case GdkEventType.KEY_PRESS, GdkEventType.KEY_RELEASE: ek := createEventKey(obj) ek.EventAny = eventAny return ek case GdkEventType.BUTTON_PRESS, GdkEventType.BUTTON_PRESS_2, GdkEventType.BUTTON_PRESS_3, GdkEventType.BUTTON_RELEASE: eb := createEventButton(obj) eb.EventAny = eventAny return eb } return eventAny }
func createEventButton(obj unsafe.Pointer) EventButton { eb := (*C.GdkEventButton)(obj) eventButton := EventButton{} eventButton.Time = uint32(eb.time) eventButton.X = float64(eb.x) eventButton.Y = float64(eb.y) eventButton.State = uint(eb.state) eventButton.Button = uint(eb.button) eventButton.Device = nil if gd, err := gobject.ConvertToGo(unsafe.Pointer(eb.device), GdkType.DEVICE); err == nil { eventButton.Device = gd.(*Device) } eventButton.X_Root = float64(eb.x_root) eventButton.Y_Root = float64(eb.y_root) return eventButton }