On 03/07/12 10:06, blue146 wrote:
> Can someone post an example of a function that handles single-click events 
> and double-click events. It seems to be non-trivial task, and even though 
> many people may need it I could not find an example anywhere.

    You'd want to use: Fl::event_clicks(); in your handle()
    function to detect multi-click operations.

    Here's a compilable example showing how it's used.
    This counts the number of multi-clicks in the window area,
    and prints a message on the tty with the count:

#include <FL/Fl.H>
#include <FL/Fl_Window.H>
//
// Example: how to count clicks on a widget 03/07/12
//
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:
                printf("Number of clicks: %d\n", (Fl::event_clicks()+1));
                break;
        }
        return(Fl_Window::handle(e));
    }
};
int main() {
    MyWindow win(300,200,"Counts clicks in window");
    win.show();
    return(Fl::run());
}

_______________________________________________
fltk mailing list
fltk@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to