/* * Run a menu. * * If popup is true, the screen is saved before the menu is drawn, and * restored afterwards. Each time a popup menu is redrawn, it resets the * screen before redrawing. */ public ui_event select(ui_event_type notify, bool popup) { ui_event min = new ui_event(); //EVENT_EMPTY; bool no_act = ((flags & (int)menu_type_flags.MN_NO_ACTION) == 1) ? true : false; Misc.assert(active.width != 0 && active.page_rows != 0); notify |= (ui_event_type.EVT_SELECT | ui_event_type.EVT_ESCAPE); if (popup) { Utilities.screen_save(); } /* Stop on first unhandled event */ while ((min.type & notify) == 0) { ui_event mout = new ui_event(); refresh(popup); min = Utilities.inkey_ex(); /* Handle mouse & keyboard commands */ if (min.type == ui_event_type.EVT_MOUSE) { handle_mouse(min, out mout); } else if (min.type == ui_event_type.EVT_KBRD) { if (!no_act && (cmd_keys != null && cmd_keys.Length > 0) && cmd_keys.IndexOf((char)min.key.code) >= 0 && handle_action(min)) { continue; } handle_keypress(min, ref mout); } else if (min.type == ui_event_type.EVT_RESIZE) { menu_calc_size(); if (row_funcs.resize != null) { row_funcs.resize(this); } } /* XXX should redraw menu here if cursor has moved */ /* If we've selected an item, then send that event out */ if (mout.type == ui_event_type.EVT_SELECT && !no_act && handle_action(mout)) { continue; } /* Notify about the outgoing type */ if ((notify & mout.type) != (ui_event_type)0) { if (popup) { Utilities.screen_load(); } return(mout); } } if (popup) { Utilities.screen_load(); } return(min); }
/* * Run a menu. * * If popup is true, the screen is saved before the menu is drawn, and * restored afterwards. Each time a popup menu is redrawn, it resets the * screen before redrawing. */ public ui_event select(ui_event_type notify, bool popup) { ui_event min = new ui_event(); //EVENT_EMPTY; bool no_act = ((flags & (int)menu_type_flags.MN_NO_ACTION) == 1) ? true : false; Misc.assert(active.width != 0 && active.page_rows != 0); notify |= (ui_event_type.EVT_SELECT | ui_event_type.EVT_ESCAPE); if(popup) { Utilities.screen_save(); } /* Stop on first unhandled event */ while ((min.type & notify) == 0) { ui_event mout = new ui_event(); refresh(popup); min = Utilities.inkey_ex(); /* Handle mouse & keyboard commands */ if (min.type == ui_event_type.EVT_MOUSE) { handle_mouse(min, out mout); } else if (min.type == ui_event_type.EVT_KBRD) { if (!no_act && (cmd_keys != null && cmd_keys.Length > 0) && cmd_keys.IndexOf((char)min.key.code) >= 0 && handle_action(min)) continue; handle_keypress(min, ref mout); } else if (min.type == ui_event_type.EVT_RESIZE) { menu_calc_size(); if (row_funcs.resize != null) row_funcs.resize(this); } /* XXX should redraw menu here if cursor has moved */ /* If we've selected an item, then send that event out */ if (mout.type == ui_event_type.EVT_SELECT && !no_act && handle_action(mout)) continue; /* Notify about the outgoing type */ if ((notify & mout.type) != (ui_event_type)0) { if(popup) { Utilities.screen_load(); } return mout; } } if(popup) { Utilities.screen_load(); } return min; }
public ui_event() { type = ui_event_type.EVT_NONE; key = null; mouse = null; }