MCPcopy Index your code
hub / github.com/python/cpython / right_menu_event

Method right_menu_event

Lib/idlelib/editor.py:503–536  ·  view source on GitHub ↗
(self, event)

Source from the content-addressed store, hash-verified

501 rmenu = None
502
503 def right_menu_event(self, event):
504 text = self.text
505 newdex = text.index(f'@{event.x},{event.y}')
506 try:
507 in_selection = (text.compare('sel.first', '<=', newdex) and
508 text.compare(newdex, '<=', 'sel.last'))
509 except TclError:
510 in_selection = False
511 if not in_selection:
512 text.tag_remove("sel", "1.0", "end")
513 text.mark_set("insert", newdex)
514 if not self.rmenu:
515 self.make_rmenu()
516 rmenu = self.rmenu
517 self.event = event
518 iswin = sys.platform[:3] == 'win'
519 if iswin:
520 text.config(cursor="arrow")
521
522 for item in self.rmenu_specs:
523 try:
524 label, eventname, verify_state = item
525 except ValueError: # see issue1207589
526 continue
527
528 if verify_state is None:
529 continue
530 state = getattr(self, verify_state)()
531 rmenu.entryconfigure(label, state=state)
532
533 rmenu.tk_popup(event.x_root, event.y_root)
534 if iswin:
535 self.text.config(cursor="ibeam")
536 return "break"
537
538 rmenu_specs = [
539 # ("Label", "<<virtual-event>>", "statefuncname"), ...

Callers

nothing calls this directly

Calls 8

make_rmenuMethod · 0.95
entryconfigureMethod · 0.80
indexMethod · 0.45
compareMethod · 0.45
tag_removeMethod · 0.45
mark_setMethod · 0.45
configMethod · 0.45
tk_popupMethod · 0.45

Tested by

no test coverage detected