pushparaj muthu wrote:
> int drawmouse::handle(int event)
> {
>    printf("\n value of event :%d", event );   // getting event name
>    switch(event)
>      {
>                case FL_PUSH:
>                         flag = 1;
>                         prevx = Fl::event_x();
>                         prevy = Fl::event_y();
>                        return 1;
>                 case FL_DRAG:
>                         if(flag == 1)
>                         {
>                               damage(FL_DAMAGE_USER1);
>                         }
>                         return 1;
>                 case FL_RELEASE:
>                         flag = 0;
>                         return 1;
>                   default:
>                     return Fl_Widget::handle(event);
>         }
> }

        One problem with the above is the switch/case logic
        eclipses the PUSH/DRAG/RELEASE events from Fl_Widget,
        because when those events are received, Fl_Widget::handle(event)
        is not being called.

        You don't want to starve the base widget of these events, or it
        won't know about them.

        Move the call to Fl_Widget::handle(event) *above* the switch
        statement, so that it's always called, regardless of the event
        received, eg:

            int ret = Fl_Widget::handle(event);
            switch ( event )
            {
                case ..
                    return(1);
                case ..
                    return(1);
            }
            return(ret);        // preserve return value from 
Fl_Widget::handle()

        Also: Is 'drawmouse' a widget derived from Fl_Button
        or Fl_Widget?

        If Fl_Button, then you should be calling Fl_Button::handle()
        instead of Fl_Widget::handle(), so that the button gets the
        events.

        But if your widget actually derives from Fl_Widget, and are
        wanting button behaviors, then you should really be deriving
        your class from Fl_Button.
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to