void ComboBrowser::browser_cb(Fl_Widget *w, void *data) { // we get callbacks for all keys? if(Fl::event_key() != FL_Enter && Fl::event_key() != ' ') return; ComboBrowser *br = (ComboBrowser *)w; Fl_Input_Browser *combo = (Fl_Input_Browser *)data; Fl_Widget *item = br->item(); if(!item) return; if (item->is_group()) return; // can't select a group! combo->item(item); combo->value(item->label().c_str()); combo->redraw(FL_DAMAGE_VALUE); combo->hide_popup(); combo->do_callback(); }
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); }