Thanks to visit codestin.com
Credit goes to github.com

Skip to content

gh-125349: IDLE - fix: unexpected behavior caused by the input method #125352

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
15 changes: 11 additions & 4 deletions Lib/idlelib/multicall.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,20 +334,27 @@ def __init__(self, *args, **kwargs):
def bind(self, sequence=None, func=None, add=None):
#print("bind(%s, %s, %s)" % (sequence, func, add),
# file=sys.__stderr__)
def wrapper(event):
if event.type == tkinter.EventType.Key:
# Check for any mismatch between event.char and event.keysym
if (len(event.char) and event.char.isprintable()
and event.char.lower() != event.keysym.lower()):
return None
return func(event)
if type(sequence) is str and len(sequence) > 2 and \
sequence[:2] == "<<" and sequence[-2:] == ">>":
if sequence in self.__eventinfo:
ei = self.__eventinfo[sequence]
if ei[0] is not None:
for triplet in ei[1]:
self.__binders[triplet[1]].unbind(triplet, ei[0])
ei[0] = func
ei[0] = wrapper
if ei[0] is not None:
for triplet in ei[1]:
self.__binders[triplet[1]].bind(triplet, func)
self.__binders[triplet[1]].bind(triplet, wrapper)
else:
self.__eventinfo[sequence] = [func, []]
return widget.bind(self, sequence, func, add)
self.__eventinfo[sequence] = [wrapper, []]
return widget.bind(self, sequence, wrapper, add)

def unbind(self, sequence, funcid=None):
if type(sequence) is str and len(sequence) > 2 and \
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed unexpected behavior caused by the input method.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to be chinese, You should explain in detail in NEWS that the chinese input method is not correct.
Otherwise this will confuse the user because it doesn't know what language the input method is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At the moment, I'm not sure if this problem only occurs with Chinese input methods, and maybe with input methods in other languages. Because the root cause of the problem is not linguistic.

Loading