On 7 Mar 2012, at 20:12, blue146 wrote:
> The thing is that when it's a double click you will first print 1 and then 2.
> Could you post an example that prints "single" when it's a single click and
> only prints "double" (without printing "single" as well) when it's a
> double-click ?
>
Sure, there are a couple of ways to go about that, but it turns out it's often
not really that useful, so there's no built-in way of doing it.
You can easily do something with timeouts in the user-space, for example,
something like this will work.
/*
// Example: how to count clicks on a widget 03/07/12 (that's 2012-03-07 for
people who don't grok American date formats of course!)
*/
#include <stdio.h>
#include <stdint.h>
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
static void wait_click(void *v)
{
intptr_t cc = (intptr_t)v;
int ic = (int)(cc & 0x0F) + 1;
printf("Number of clicks: %d\n", ic);
}
static void timer_extend(int cc)
{
if(cc) Fl::remove_timeout(wait_click);
Fl::add_timeout(0.25, wait_click, (void*)cc);
}
class MyWindow : public Fl_Window {
public:
MyWindow(int W,int H,const char *L=0) : Fl_Window(W,H,L) {
}
int handle(int e) {
switch (e) {
case FL_PUSH:
timer_extend(Fl::event_clicks());
break;
}
return(Fl_Window::handle(e));
}
};
int main() {
MyWindow win(300,200,"Counts clicks in window");
win.show();
return Fl::run();
}
/* end of file */
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk