On 18 Jul 2009, at 14:10, andrei_c wrote:

> When I pres the right arrow key it does nothing.

Your ::handle() method is attempting to process window events as if  
they were keyboard events, which will not work, so you need to do  
something a bit more elaborate here:

Here's the example I worked up - although it seems to be broadly  
equivalent to Albrecht's version, so probably you already have the  
answers... Tested on OSX with your first example code, works as  
expected.


/* handle the event */
int Canvas::handle(int event)
{
        int result = Fl_Box::handle(event);
        switch(event)
        {
        case FL_KEYBOARD:
        switch(Fl::event_key())
        {
                case FL_Right:
                XC = XC + 1;
                redraw();
                return 1;

                case FL_Left:
                XC = XC - 1;
                redraw();
                return 1;

                case FL_Up:
                YC = YC - 1;
                redraw();
                return 1;

                case FL_Down:
                YC = YC + 1;
                redraw();
                return 1;

                default:
                return result;
        }

        case FL_FOCUS:
        case FL_PUSH:
        return 1;

        default:
        return result;
        }
} // Canvas::handle


-- 
Ian



_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to