int MenuBar::handle(int event) { const MenuItem* v; if (menu() && menu()->text) switch (event) { case FL_ENTER: case FL_LEAVE: return 1; case FL_PUSH: v = 0; J1: v = menu()->pulldown(x(), y(), w(), h(), v, this, 0, 1); picked(v); return 1; case FL_SHORTCUT: if (visible_r()) { v = menu()->find_shortcut(); if (v && v->submenu()) goto J1; } return test_shortcut() != 0; } return 0; }
int Fl_Button::handle(int event) { static bool oldval; static bool already_pushed=false; bool newval; switch (event) { case FL_LEAVE: case FL_ENTER: if (highlight_color() && takesevents()) redraw(FL_DAMAGE_HIGHLIGHT); case FL_MOVE: return 1; case FL_PUSH: if(!already_pushed) oldval = value(); already_pushed = true; case FL_DRAG: if (Fl::event_inside(0,0,w(),h())) { held_down = this; if (type() == RADIO) newval = true; else newval = !oldval; } else { held_down = 0; newval = oldval; } if (value(newval) && when()&FL_WHEN_CHANGED) do_callback((void*)value()); return 1; case FL_RELEASE: redraw(FL_DAMAGE_VALUE); held_down = 0; already_pushed = false; if (value() == oldval) return 1; if (type() == RADIO) setonly(); else if (type()) // TOGGLE ; // leave it as set else { value(oldval); if (when() & FL_WHEN_CHANGED) do_callback((void*)value()); } if (when() & FL_WHEN_RELEASE) do_callback((void*)value()); else set_changed(); return 1; case FL_UNFOCUS: case FL_FOCUS: redraw(FL_DAMAGE_HIGHLIGHT); // grab initial focus if we are an Fl_Return_Button: return shortcut()=='\r' ? 2 : 1; case FL_SHORTCUT: case FL_KEY: if(event==FL_SHORTCUT && !test_shortcut()) return 0; if(event==FL_KEY && Fl::event_key() != ' ' && Fl::event_key() != FL_Enter ) return 0; if (type() == RADIO/* && !value()*/) { setonly(); if (when() & FL_WHEN_CHANGED) do_callback((void*)value()); } // TOGGLE else if (type()) { value(!value()); if (when() & FL_WHEN_CHANGED) do_callback((void*)value()); } if (when() & FL_WHEN_RELEASE) do_callback((void*)value()); else set_changed(); return 1; default: break; } return Fl_Widget::handle(event); }