Skip to content

Commit

Permalink
Actually work with various quit events (menu, shortcut, osascript)
Browse files Browse the repository at this point in the history
  • Loading branch information
ronaldoussoren committed Dec 27, 2023
1 parent a0bb7ab commit eda5750
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 7 additions & 0 deletions Lib/idlelib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

from tkinter.font import Font
import idlelib
from idlelib import macosx

class InvalidConfigType(Exception): pass
class InvalidConfigSet(Exception): pass
Expand Down Expand Up @@ -660,6 +661,12 @@ def GetCoreKeys(self, keySetName=None):
'<<zoom-height>>': ['<Alt-Key-2>'],
}

if sys.platform == "darwin":
# XXX: ^^^ This test should be macosx.isAquaTk(),
# but that has some side effect that results in not
# calling the quit event handler.
del keyBindings['<<close-all-windows>>']

if keySetName:
if not (self.userCfg['keys'].has_section(keySetName) or
self.defaultCfg['keys'].has_section(keySetName)):
Expand Down
4 changes: 1 addition & 3 deletions Lib/idlelib/macosx.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,12 +216,10 @@ def help_dialog(event=None):
root.bind('<<open-config-dialog>>', config_dialog)
root.createcommand('::tk::mac::ShowPreferences', config_dialog)
if flist:
root.bind('<<close-all-windows>>', flist.close_all_callback)

# The binding above doesn't reliably work on all versions of Tk
# on macOS. Adding command definition below does seem to do the
# right thing for now.
root.createcommand('::tk::mac::Quit', lambda: "break")
root.createcommand('::tk::mac::Quit', flist.close_all_callback)

if isCarbonTk():
# for Carbon AquaTk, replace the default Tk apple menu
Expand Down

0 comments on commit eda5750

Please sign in to comment.