Re: Click (GDK_BUTTON_PRESS & _RELEASE) in GDK



"Vassilios V . Dimakopoulos" <dimako cs uoi gr> writes:

Here is my problem:
I am drawing objects on a drawing area and process GDK_BUTTON_PRESS and
GDK_BUTTON_RELEASE events in it; however I would like to have a third type
of event like "BUTTON_CLICK" (_PRESS immediately followed by a _RELEASE).
For example, "_CLICK" would just select an object, while _PRESS would 
start moving an object till a _RELEASE is encounterd.

It there a simple way to do this?


One way this is often done is to have a threshold distance; i.e. when
you get a _PRESS, record the mouse coordinates in the press event;
when you get motion notifies, if the mouse has moved more than a few
pixels then start a drag; when you get button release, if a drag
hasn't been started, then it was just a click. 

You could also combine that with some delay as Mark suggested, a click
has to have the release within 1 second of the press or something.

With those two heuristics you'll usually do what the user meant.

Havoc




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]