classification
Title: Right Click Context Menu
Type: enhancement Stage: patch review
Components: IDLE Versions: Python 3.2
process
Status: open Resolution: accepted
Dependencies: Superseder:
Assigned To: Nosy List: Nashev, gpolo, kbk, michael.foord, rhettinger, taleinat, terry.reedy
Priority: normal Keywords: patch

Created on 2005-05-24 08:31 by michael.foord, last changed 2010-07-20 14:13 by taleinat.

Files
File name Uploaded Description Edit
rightmenu_copypastecut.diff gpolo, 2009-08-10 17:46 review
IDLE_rmenu_trunk.patch taleinat, 2010-07-20 14:12 patch after review changes (against trunk) review
IDLE_rmenu_py3k.patch taleinat, 2010-07-20 14:13 patch after review changes (against py3k) review
Messages (8)
msg54525 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2005-05-24 08:31
It would be useful if the right click context menu had the 
usual 'cut/paste/copy' options - as in most other IDEs. 

I regularly lose my selection because IDLE doesn't 
behave the same way as most other editors in this 
regard.
msg54526 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2005-05-26 07:06
Logged In: YES 
user_id=80475

+0

Control-X, Control-C, and Control-V work fine for me.  

Still, the OP's suggestion is a standard way of doing things.
msg54527 - (view) Author: Michael Foord (michael.foord) * (Python committer) Date: 2005-05-26 07:46
Logged In: YES 
user_id=1123892

It's a standard way of doing things (and so an ingrained habit 
for at least windoze users) - and also if you're using the 
mouse to make a selection and then change focus to another 
window to paste into it; it's easier to be able to do the whole 
operation with the mouse than change to the keyboard and 
back again.
msg54528 - (view) Author: Kurt B. Kaiser (kbk) * (Python committer) Date: 2005-05-26 15:38
Logged In: YES 
user_id=149084

This came up on idle-dev, as I remember.

Seems like a reasonable suggestion to me.

Maybe OP could write a patch? All the pertinent code
should be in EditorWindow.py.
msg59661 - (view) Author: Nashev (Nashev) Date: 2008-01-10 12:31
1) in file EditorWindow.py 2 editings:

a) remove selection-killer command on popup

    def right_menu_event(self, event):
--      self.text.tag_remove("sel", "1.0", "end")

b) add ability to make separators in popup menu

    def make_rmenu(self):
        rmenu = Menu(self.text, tearoff=0)
        for label, eventname in self.rmenu_specs:
++          if label != "-":
                def command(text=self.text, eventname=eventname):
                    text.event_generate(eventname)
                rmenu.add_command(label=label, command=command)
++          else:
++              rmenu.add_separator()
        self.rmenu = rmenu

2) in PyShell.py extend rmenu_specs

    rmenu_specs = [
++      ("Cut", "<<Cut>>"), 
++      ("Copy", "<<Copy>>"),
++      ("Paste", "<<Paste>>"),
++      ("-", ""),
        ("Set Breakpoint", "<<set-breakpoint-here>>"),
        ("Clear Breakpoint", "<<clear-breakpoint-here>>")
    ]

done...

And now I can't find easy way to next two desired features:
  1) disable cut/copy commands in case no selection (but it is not
exists in main menu too)
  2) display assigned hot keys in popup menu
msg91457 - (view) Author: Guilherme Polo (gpolo) * (Python committer) Date: 2009-08-10 17:46
What do you think about adding a third element for each tuple in
rmenu_specs ? This new element would be a string determining the name of
a function that would be called to define the state of each entry in the
right menu. If None is used in place of a string, then it is assumed
that the entry doesn't require such thing.

Attaching a patch that does that. It also adds cut/copy/paste to the
right menu in IDLE shell.
msg91458 - (view) Author: Guilherme Polo (gpolo) * (Python committer) Date: 2009-08-10 17:48
> 2) display assigned hot keys in popup menu

Is that really necessary ? I've looked for that on some applications I
use most and none of them include hot keys in right menus.
msg110901 - (view) Author: Tal Einat (taleinat) (Python committer) Date: 2010-07-20 14:12
I agree with Guilherme: shortcuts don't need to appear in the context menu.

Guilherme's patch looks pretty good overall, but I have a few remarks:

1) Pasting should be disabled in the Shell window when the cursor is before the I/O mark. (the behavior for cutting is correct)

2) Code relevant to the Shell window should be in PyShell, not in EditorWindow with a getattr(self, 'interp', None) check.

3) Tk.Text.compare can receive names of tags to compare (don't have to do Tk.Text.index('<tag name>'))

So I made these changes. Attached are patches against current trunk (2.x) and py3k branch.

My testing on Windows7 with both 2.7 and 3.1.2 showed this change works well. This should be tested on OSX and Linux since it interacts with the clipboard, which works differently on these platforms.
History
Date User Action Args
2010-07-20 14:13:20taleinatsetfiles: + IDLE_rmenu_py3k.patch
2010-07-20 14:12:45taleinatsetfiles: + IDLE_rmenu_trunk.patch
nosy: + taleinat
messages: + msg110901

2010-07-16 13:09:37BreamoreBoysetnosy: + terry.reedy

versions: + Python 3.2, - Python 3.1, Python 2.7
2009-08-10 17:48:59gpolosetmessages: + msg91458
2009-08-10 17:46:38gpolosetfiles: + rightmenu_copypastecut.diff

messages: + msg91457
2009-04-26 22:19:22ajaksu2setkeywords: + patch
nosy: + gpolo

stage: test needed -> patch review
2009-03-04 15:16:37ajaksu2setstage: test needed
versions: + Python 3.1, Python 2.7
2008-01-10 12:31:43Nashevsetnosy: + Nashev
messages: + msg59661
2005-05-24 08:31:45mjfoordcreate