Ejemplo n.º 1
0
int ComboWindow::handle(int event)
{
    static bool resizing = false;

    switch (event) {
        case FL_PUSH: {
                Fl_Rect size_grip(w()-SIZE_GRIP, h()-SIZE_GRIP, SIZE_GRIP, SIZE_GRIP);
                if(size_grip.posInRect(Fl::event_x(), Fl::event_y())) {
                    resizing = true;            
                    return 1;
                }       
                break;
            }

        case FL_DRAG:
            if(resizing) {
                int W=Fl::event_x(), H=Fl::event_y();
                if(W < combo->w()) W = combo->w();
                if(H < combo->h()) H = combo->h();
                size(W, H);
                combo->list->Fl_Group::size(W-box()->dw(), H-SIZE_GRIP-box()->dh());
                return 1;
            }
            break;

        case FL_RELEASE:
            if(resizing) {
                resizing=false;
                return 1;
            }
            break;

        case FL_KEY:
        case FL_MOVE:
            if(combo->list) combo->list->handle(event);
            return 1;

        default:
            break;
    }
    return Fl_Menu_Window::handle(event);
}
Ejemplo n.º 2
0
int ComboBrowser::handle(int event)
{
    // Work-around...
    if(Fl::event_key()==FL_Down && (!item() || children()==1)) {
        item(child(0));
        Fl_Group::focus(item());
    }   

    if((event==FL_SHORTCUT||event==FL_KEY) && !(combo->type()&Fl_Input_Browser::NONEDITABLE)) {
        if( (Fl::event_key()!=FL_Escape) &&
                (Fl::event_key()!=FL_Up) &&
                (Fl::event_key()!=FL_Down) &&
                !(Fl::event_key()==FL_Enter && item()) )
            return combo->input()->handle(FL_KEY);
    }

    static bool was_wheel=false;
    if(was_wheel) {
        was_wheel=false;
        return 1;
    }

    switch (event) {
        case FL_MOUSEWHEEL: {
                was_wheel=true;
                break;
            }

        case FL_KEY:
        case FL_SHORTCUT:
            if(Fl::event_key() == FL_Escape) {
                combo->hide_popup();
                return 1;
            }
            break;

        case FL_PUSH: {
                Fl::event_clicks(1);
                Fl_Rect size_grip(w()-SIZE_GRIP, h(), SIZE_GRIP, SIZE_GRIP);
                if(size_grip.posInRect(Fl::event_x(), Fl::event_y())) return 1;

                if(Fl::event_x() > w() || Fl::event_x() < x() ||
                        Fl::event_y() > h() || Fl::event_y() < y() ) {
                    combo->hide_popup();
                    if(Fl::event_y() < y()-combo->h()) combo->send(FL_PUSH);
                    return 1;
                }
                break;
            }

        case FL_MOVE:
            event = FL_DRAG;

        case FL_RELEASE:
        case FL_DRAG:
        // this causes a drag-in to the widget to work:
            if (Fl::event_inside(0, 0, w(), h()))
                Fl::pushed(this);
            else {
                Fl::pushed(0);
                return 0;
            }

        default:
            break;
    }

    return Fl_Browser::handle(event);
}