//export our_area_button_press_event_callback func our_area_button_press_event_callback(widget *C.GtkWidget, event *C.GdkEvent, data C.gpointer) C.gboolean { // clicking doesn't automatically transfer keyboard focus; we must do so manually (thanks tristan in irc.gimp.net/#gtk+) C.gtk_widget_grab_focus(widget) e := (*C.GdkEventButton)(unsafe.Pointer(event)) me := MouseEvent{ // GDK button ID == our button ID with some exceptions taken care of by finishMouseEvent() Down: uint(e.button), } var maxTime C.gint var maxDistance C.gint if e._type != C.GDK_BUTTON_PRESS { // ignore GDK's generated double-clicks and beyond; we handled those ourselves below return continueEventChain } s := (*sysData)(unsafe.Pointer(data)) // e.time is unsigned and in milliseconds // maxTime is also milliseconds; despite being gint, it is only allowed to be positive // maxDistance is also only allowed to be positive settings := C.gtk_widget_get_settings(widget) C.gtkGetDoubleClickSettings(settings, &maxTime, &maxDistance) me.Count = s.clickCounter.click(me.Down, int(e.x), int(e.y), uintptr(e.time), uintptr(maxTime), int(maxDistance), int(maxDistance)) finishMouseEvent(widget, data, me, me.Down, e.x, e.y, e.state, e.window) return continueEventChain }
func (a *area) OpenTextFieldAt(x, y int) { if x < 0 || x >= a.width || y < 0 || y >= a.height { panic(fmt.Errorf("point (%d,%d) outside Area in Area.OpenTextFieldAt()", x, y)) } a.textfieldx = x a.textfieldy = y a.inmenu = false // to start // we disabled this for the initial Area show; we don't need to anymore C.gtk_widget_set_no_show_all(a.textfieldw, C.FALSE) C.gtk_widget_show_all(a.textfieldw) C.gtk_widget_grab_focus(a.textfieldw) }
func (self *Widget) GrabFocus() { C.gtk_widget_grab_focus(self.object) }
// GrabFocus() is a wrapper around gtk_widget_grab_focus(). func (v *Widget) GrabFocus() { C.gtk_widget_grab_focus(v.native()) }
func gtk_widget_grab_focus(p GtkWidget) { C.gtk_widget_grab_focus(Arg(p)) }