def context_menu(self, x, y): """ Show context menu at the coordinate. """ index = self.get_selected_entry_index() if index < 0: return _ = self.res.get popup = self._context_menu if popup is None: popup = PopupMenuWrapper(self.ctx, ( MenuEntry(_("Go to Cell"), 4, 0, "goto"), MenuEntry(_("Go to"), 6, 1, "gotocell"), MenuEntry(_("Remove"), 8, 2, "delete"), MenuEntry("", -1, 3), MenuEntry(_("Up"), 10, 4, "up"), MenuEntry(_("Down"), 11, 5, "down") ), True) self._context_menu = popup if popup: addr = self.get_selected_entry_heading() state = False if addr: refs = self.model.get_cell_references(addr) if refs: popup.setPopupMenu( 6, PopupMenuWrapper( self.ctx, [MenuEntry(ref, i + 1000, i, "") for i, ref in enumerate(refs)], False ) ) state = True popup.enableItem(6, state) popup.enableItem(10, self.is_selected_entry_moveable(True)) popup.enableItem(11, self.is_selected_entry_moveable(False)) ps = self.grid.getPosSize() n = popup.execute(self.cont.getPeer(), x + ps.X, y + ps.Y) if n > 0 and n < 1000: self.execute_cmd(popup.getCommand(n)) elif n >= 1000: addr = refs[n - 1000] self.cmd_goto(addr)
def option_popup(self, x, y): """ Show popup menu for option button. """ _ = self.res.get popup = PopupMenuWrapper(self.ctx, ( MenuEntry(_("Clear"), 32, 0, "clear"), MenuEntry("", -1, 1, ""), MenuEntry(_("Input line"), 1024, 2, "switch_inputline", style=MIS_CHECKABLE), MenuEntry(_("Store watches"), 2048, 3, "switch_store", style=MIS_CHECKABLE), MenuEntry("", -1, 4, ""), MenuEntry(_("Settings..."), 512, 5, "settings"), MenuEntry(_("About"), 4096, 6, "about"), ), True) popup.checkItem(1024, self.input_line_shown) popup.checkItem(2048, self.model.store_watches) n = popup.execute(self.cont.getPeer(), x, y) if n > 0: self.execute_cmd(popup.getCommand(n))