You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
OS X IDLE 3.2 Save As menu accelerator opens two Save windows #55264
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee='https://github.com/ned-deily'closed_at=<Date2011-07-22.01:38:21.918>created_at=<Date2011-01-29.04:03:38.278>labels= ['OS-mac', 'expert-IDLE']
title='OS X IDLE 3.2 Save As menu accelerator opens two Save windows'updated_at=<Date2011-07-22.01:38:21.916>user='https://github.com/ned-deily'
With the menu accelerators corrected (as patched in bpo-10940), IDLE 3.2 with Cocoa Tk 8.5 opens two Save As dialog windows instead of one. This doesn't happen when the Save As item is selected with the mouse nor does it happen with Carbon Tk 8.4. The simple workaround is to dismiss the second dialog window. This can be investigated and fixed post 3.2 release.
Both 3.2 and 3.3 fail can be used. Install the framework and then open an existing file, use SHIFT+CMD+S to save the file and you'll see two dialogs (both labelled 'Save').
Some investigation learns that the save_as method in IOBindings gets called twice.
The attached patch (for 3.2) is a crude hack, but does result in a working copy of IDLE that doesn't show two save dialogs.
I'm inclined to commit the patch, it is a hack but there are already other workarounds for Tk-on-OSX weirdness.
This is not caused by unwanted interaction with Tk's default bindings, changing the save-as bindings to Shift+Cmd+M doesn't "fix" the issue.
It seems that the save event is generated twice, for reasons I don't yet understand (I'm definitely not enough of a Tkinter user to understand what's going on).
I have attached a new patch that fixes the issue for me, by recognizing that a save event is getting in while already saving. The fix is only active on OSX.
BTW. This issue probably also affects 2.7, I haven't done a rebuild of 2.7 yet to check that.
Another data point: the key binding for Undo (Shift-Command-Z) exhibits similar behavior, i.e. it is executed twice. And trying with Python 2.7.1 linked with A/S Tk 8.5 and with the old key bindings where Shift-Command-S is Save Copy rather than Save As, it appears that now two Save Copy events happen. So it appears to happen in general (?) when Shift is combined with another accelerator. But it doesn't happen with Option-Command-S in 3.2. And, using the Wish 8.5 menu demo, I was not able to reproduce the problem there by simply changing the accelerators to from Command-<letter> to Shift-Command-<letter>. So it's hard not to rule out something in IDLE yet.
The double execution is definitely caused by having multiple event, one of which is a real keyboard event and the other one is a ghost one.
I'm seeing calls to save_as with 2 events: the first is a ghost event, with type 35 and '??' as the keycode and keysym. The second one seems to be the real event with type 2, keysym 'S' and keycode 65651.
The actual unwanted event is being generated as a result of the menu "add command" accelerator. You can see that by playing with Wish.
set w .menu
catch {destroy $w}
toplevel $w
wm title $w "Menu Shift"
menu $w.menu -tearoff 0
set m $w.menu.basic
$w.menu add cascade -label "Basic" -menu $m -underline 0
menu $m -tearoff 0
It appears that there is a bug in the Cocoa Tk right now where accelerators with "Shift" (at least) in them are not being properly ignored by Tk. In the Carbon Tk and the X11 Tk, I believe the only effect of the "accelerator" definitions on the "add command" is to be used to create the shortcut characters displayed in the menu entry. However, apparently a side effect of using the Cocoa APIs is that the menu definitions now cause notifications back into Tk which are not supposed to be translated into Tcl/Tk events back to the app. For some reason, the shift ones are not being ignored.
Activity
ned-deily commentedon Jan 29, 2011
With the menu accelerators corrected (as patched in bpo-10940), IDLE 3.2 with Cocoa Tk 8.5 opens two Save As dialog windows instead of one. This doesn't happen when the Save As item is selected with the mouse nor does it happen with Carbon Tk 8.4. The simple workaround is to dismiss the second dialog window. This can be investigated and fixed post 3.2 release.
ronaldoussoren commentedon Mar 15, 2011
To reproduce install ActiveState Tcl 8.5.9 and then build python using:
../configure --enable-framework --enable-universalsdk=/ --with-universal-archs=intel MACOSX_DEPLOYMENT_TARGET=10.6
Both 3.2 and 3.3 fail can be used. Install the framework and then open an existing file, use SHIFT+CMD+S to save the file and you'll see two dialogs (both labelled 'Save').
Some investigation learns that the save_as method in IOBindings gets called twice.
The attached patch (for 3.2) is a crude hack, but does result in a working copy of IDLE that doesn't show two save dialogs.
I'm inclined to commit the patch, it is a hack but there are already other workarounds for Tk-on-OSX weirdness.
Comments?
ronaldoussoren commentedon Mar 15, 2011
Please ignore the patch, it doesn't work after all. It was too good to be true after all.
ronaldoussoren commentedon Mar 15, 2011
This is not caused by unwanted interaction with Tk's default bindings, changing the save-as bindings to Shift+Cmd+M doesn't "fix" the issue.
It seems that the save event is generated twice, for reasons I don't yet understand (I'm definitely not enough of a Tkinter user to understand what's going on).
I have attached a new patch that fixes the issue for me, by recognizing that a save event is getting in while already saving. The fix is only active on OSX.
BTW. This issue probably also affects 2.7, I haven't done a rebuild of 2.7 yet to check that.
ned-deily commentedon Mar 16, 2011
Another data point: the key binding for Undo (Shift-Command-Z) exhibits similar behavior, i.e. it is executed twice. And trying with Python 2.7.1 linked with A/S Tk 8.5 and with the old key bindings where Shift-Command-S is Save Copy rather than Save As, it appears that now two Save Copy events happen. So it appears to happen in general (?) when Shift is combined with another accelerator. But it doesn't happen with Option-Command-S in 3.2. And, using the Wish 8.5 menu demo, I was not able to reproduce the problem there by simply changing the accelerators to from Command-<letter> to Shift-Command-<letter>. So it's hard not to rule out something in IDLE yet.
ronaldoussoren commentedon Mar 16, 2011
The double execution is definitely caused by having multiple event, one of which is a real keyboard event and the other one is a ghost one.
I'm seeing calls to save_as with 2 events: the first is a ghost event, with type 35 and '??' as the keycode and keysym. The second one seems to be the real event with type 2, keysym 'S' and keycode 65651.
ronaldoussoren commentedon Mar 16, 2011
It's getting weirder by the minute. Not only do we get multiple events, we also get additional keybindings we never asked for.
*Cmd+Ctrl+S also works as save as
*Cmd+Shift+S gives two save as events (as was already known)
ned-deily commentedon Mar 17, 2011
The actual unwanted event is being generated as a result of the menu "add command" accelerator. You can see that by playing with Wish.
set w .menu
catch {destroy $w}
toplevel $w
wm title $w "Menu Shift"
menu $w.menu -tearoff 0
set m $w.menu.basic
$w.menu add cascade -label "Basic" -menu $m -underline 0
menu $m -tearoff 0
$m add command -label "Test" \
-command "puts command" -accelerator Command-Shift-A
bind $w <Command-Shift-A> "puts bind"
$w configure -menu $w.menu
It appears that there is a bug in the Cocoa Tk right now where accelerators with "Shift" (at least) in them are not being properly ignored by Tk. In the Carbon Tk and the X11 Tk, I believe the only effect of the "accelerator" definitions on the "add command" is to be used to create the shortcut characters displayed in the menu entry. However, apparently a side effect of using the Cocoa APIs is that the menu definitions now cause notifications back into Tk which are not supposed to be translated into Tcl/Tk events back to the app. For some reason, the shift ones are not being ignored.
https://github.com/das/tcltk/blob/master/tk/macosx/tkMacOSXMenu.c
Also, it seems that with all three of the Tk implementations (Carbon, X11, and Cocoa), using a capital letter for the menu accelerator implies Shift.
ned-deily commentedon Jul 18, 2011
There is now a patch in the Tcl pipeline for this problem. See:
http://permalink.gmane.org/gmane.comp.lang.tcl.mac/6965
ned-deily commentedon Jul 22, 2011
A fix for this problem has been released in ActiveTcl 8.5.10.1 as of 2011-07-21.