Browse Source

add more info to detect double clicks

master
Alexandros Theodotou 3 years ago
parent
commit
dd10376dd5
Signed by: alex
GPG Key ID: 022EAE42313D70F3
  1. 19
      inc/ztoolkit/ztk_widget.h
  2. 2
      src/ztk_app.c

19
inc/ztoolkit/ztk_widget.h

@ -207,19 +207,30 @@ typedef struct ZtkWidget @@ -207,19 +207,30 @@ typedef struct ZtkWidget
/**
* Last time a press was finished.
*/
double last_btn_release;
/**
* Last time a press was finished, before
* the latest one.
*
* This is used to detect double clicks.
*/
double last_btn_release;
double before_last_btn_release;
/**
* Last time a button was held down.
*
* If this minus \ref ZtkWidget.last_btn_release
* is short enough, this is a double click.
*/
double last_btn_press;
/**
* Last time a button was held down,
* before the latest one.
*
* This is used to detect double clicks.
*/
double before_last_btn_press;
/** Cairo caches. */
cairo_t * cached_cr;
cairo_surface_t * cached_surface;

2
src/ztk_app.c

@ -182,6 +182,7 @@ post_event_to_widgets ( @@ -182,6 +182,7 @@ post_event_to_widgets (
is_first_widget_hit (
self, w, ev->x, ev->y))
{
w->before_last_btn_press = w->last_btn_press;
w->last_btn_press = ev->time;
w->state |=
ZTK_WIDGET_STATE_PRESSED;
@ -211,6 +212,7 @@ post_event_to_widgets ( @@ -211,6 +212,7 @@ post_event_to_widgets (
w->state &=
(unsigned int)
~ZTK_WIDGET_STATE_PRESSED;
w->before_last_btn_release = w->last_btn_release;
w->last_btn_release = ev->time;
if (w->visible &&
w->button_event_cb &&

Loading…
Cancel
Save