10000 bpo-39885: IDLE: Leave selection when right click within by terryjreedy · Pull Request #18951 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-39885: IDLE: Leave selection when right click within #18951

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 29, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
bpo-39885: IDLE: Leave selection when right click within
This exception was omitted from previous commit, 4ca060d.
  • Loading branch information
terryjreedy committed Mar 12, 2020
commit 77814484608ca81eb227666d095c7118d6aeda9b
4 changes: 2 additions & 2 deletions Lib/idlelib/NEWS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Released on 2020-10-05?
bpo-27115: For 'Go to Line', use a Query entry box subclass with
IDLE standard behavior and improved error checking.

bpo-39885: Since clicking to get an IDLE context menu moves the
cursor, any text selection should be and now is cleared.
bpo-39885: When a context menu is invoked by clicking outside of a
selection, clear the selection and move the cursor.

bpo-39852: Edit "Go to line" now clears any selection, preventing
accidental deletion. It also updates Ln and Col on the status bar.
Expand Down
15 changes: 11 additions & 4 deletions Lib/idlelib/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,15 +499,23 @@ def handle_yview(self, event, *args):
rmenu = None

def right_menu_event(self, event):
self.text.tag_remove("sel", "1.0", "end")
self.text.mark_set("insert", "@%d,%d" % (event.x, event.y))
text = self.text
newdex = text.index(f'@{event.x},{event.y}')
try:
in_selection = (text.compare('sel.first', '<=', newdex) and
text.compare(newdex, '<=', 'sel.last'))
except TclError:
in_selection = False
if not in_selection:
text.tag_remove("sel", "1.0", "end")
text.mark_set("insert", newdex)
if not self.rmenu:
self.make_rmenu()
rmenu = self.rmenu
self.event = event
iswin = sys.platform[:3] == 'win'
if iswin:
self.text.config(cursor="arrow")
text.config(cursor="arrow")

for item in self.rmenu_specs:
try:
Expand All @@ -520,7 +528,6 @@ def right_menu_event(self, event):
state = getattr(self, verify_state)()
rmenu.entryconfigure(label, state=state)


rmenu.tk_popup(event.x_root, event.y_root)
if iswin:
self.text.config(cursor="ibeam")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Since clicking to get an IDLE context menu moves the cursor,
any text selection should be and now is cleared.
When a context menu is invoked by clicking outside of a selection,
clear the selection and move the cursor.
0