Skip to content

OS X IDLE 3.2 Save As menu accelerator opens two Save windows #55264

Closed

Description

@ned-deily
BPO 11055
Nosy @ronaldoussoren, @ned-deily
Files
  • issue11055.txt
  • 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 = <Date 2011-07-22.01:38:21.918>
    created_at = <Date 2011-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 = <Date 2011-07-22.01:38:21.916>
    user = 'https://github.com/ned-deily'

    bugs.python.org fields:

    activity = <Date 2011-07-22.01:38:21.916>
    actor = 'ned.deily'
    assignee = 'ned.deily'
    closed = True
    closed_date = <Date 2011-07-22.01:38:21.918>
    closer = 'ned.deily'
    components = ['IDLE', 'macOS']
    creation = <Date 2011-01-29.04:03:38.278>
    creator = 'ned.deily'
    dependencies = []
    files = ['21231']
    hgrepos = []
    issue_num = 11055
    keywords = ['patch', 'needs review']
    message_count = 10.0
    messages = ['127378', '130995', '131000', '131052', '131087', '131164', '131165', '131233', '140559', '140854']
    nosy_count = 2.0
    nosy_names = ['ronaldoussoren', 'ned.deily']
    pr_nums = []
    priority = 'normal'
    resolution = 'out of date'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue11055'
    versions = ['Python 3.2', 'Python 3.3']

    Activity

    1. ned-deily commented on Jan 29, 2011

      @ned-deily
      MemberAuthor

      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.

    2. self-assigned this
      on Jan 29, 2011
    3. ronaldoussoren commented on Mar 15, 2011

      @ronaldoussoren
      Contributor

      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?

    4. ronaldoussoren commented on Mar 15, 2011

      @ronaldoussoren
      Contributor

      Please ignore the patch, it doesn't work after all. It was too good to be true after all.

    5. ronaldoussoren commented on Mar 15, 2011

      @ronaldoussoren
      Contributor

      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.

    6. ned-deily commented on Mar 16, 2011

      @ned-deily
      MemberAuthor

      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.

    7. ronaldoussoren commented on Mar 16, 2011

      @ronaldoussoren
      Contributor

      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.

    8. ronaldoussoren commented on Mar 16, 2011

      @ronaldoussoren
      Contributor

      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)

    9. ned-deily commented on Mar 17, 2011

      @ned-deily
      MemberAuthor

      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.

    10. ned-deily commented on Jul 18, 2011

      @ned-deily
      MemberAuthor

      There is now a patch in the Tcl pipeline for this problem. See:
      http://permalink.gmane.org/gmane.comp.lang.tcl.mac/6965

    11. ned-deily commented on Jul 22, 2011

      @ned-deily
      MemberAuthor

      A fix for this problem has been released in ActiveTcl 8.5.10.1 as of 2011-07-21.

    12. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions