diff options
| author | Pietro Gagliardi <[email protected]> | 2014-05-23 18:30:08 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-05-23 18:30:08 -0400 |
| commit | dbeccfa922d4d11ec37e27c7ebe611957eaae7f5 (patch) | |
| tree | 8313e49e9bc40fc0c8a7212491002043eea14bf3 /area_unix.go | |
| parent | b359f995f5b1079ad382cf073b0359b6dbfee79e (diff) | |
Added custom double-click/triple-click/higher-order click handling to GTK+ Areas.
Diffstat (limited to 'area_unix.go')
| -rw-r--r-- | area_unix.go | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/area_unix.go b/area_unix.go index 92e9f94..0033df6 100644 --- a/area_unix.go +++ b/area_unix.go @@ -17,6 +17,14 @@ import ( // extern gboolean our_area_motion_notify_event_callback(GtkWidget *, GdkEvent *, gpointer); // extern gboolean our_area_key_press_event_callback(GtkWidget *, GdkEvent *, gpointer); // extern gboolean our_area_key_release_event_callback(GtkWidget *, GdkEvent *, gpointer); +// /* because cgo doesn't like ... */ +// static inline void gtkGetDoubleClickSettings(GtkSettings *settings, gint *maxTime, gint *maxDistance) +// { +// g_object_get(settings, +// "gtk-double-click-time", maxTime, +// "gtk-double-click-distance", maxDistance, +// NULL); +// } import "C" func gtkAreaNew() *C.GtkWidget { @@ -157,14 +165,24 @@ func our_area_button_press_event_callback(widget *C.GtkWidget, event *C.GdkEvent // GDK button ID == our button ID with some exceptions taken care of by finishMouseEvent() Down: uint(e.button), } - switch e._type { - case C.GDK_BUTTON_PRESS: - me.Count = 1 - case C.GDK_2BUTTON_PRESS: - me.Count = 2 - default: // ignore triple-clicks and beyond; we don't handle those + + 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 C.FALSE // TODO really false? } + 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 C.FALSE // TODO really false? } |
