Skip to content
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

IDLE: support Command-click on window title on macOS #88516

Closed
aivarannamaa mannequin opened this issue Jun 8, 2021 · 10 comments
Closed

IDLE: support Command-click on window title on macOS #88516

aivarannamaa mannequin opened this issue Jun 8, 2021 · 10 comments
Assignees
Labels
3.13 bugs and security fixes OS-mac topic-IDLE type-feature A feature request or enhancement

Comments

@aivarannamaa
Copy link
Mannequin

aivarannamaa mannequin commented Jun 8, 2021

BPO 44350
Nosy @terryjreedy, @ronaldoussoren, @ned-deily, @aivarannamaa

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/terryjreedy'
closed_at = None
created_at = <Date 2021-06-08.18:13:50.362>
labels = ['OS-mac', 'expert-IDLE', '3.11']
title = 'IDLE: support Command-click on window title on macOS'
updated_at = <Date 2021-06-08.21:25:08.906>
user = 'https://github.com/aivarannamaa'

bugs.python.org fields:

activity = <Date 2021-06-08.21:25:08.906>
actor = 'terry.reedy'
assignee = 'terry.reedy'
closed = False
closed_date = None
closer = None
components = ['IDLE', 'macOS']
creation = <Date 2021-06-08.18:13:50.362>
creator = 'Aivar.Annamaa'
dependencies = []
files = []
hgrepos = []
issue_num = 44350
keywords = []
message_count = 3.0
messages = ['395348', '395349', '395363']
nosy_count = 4.0
nosy_names = ['terry.reedy', 'ronaldoussoren', 'ned.deily', 'Aivar.Annamaa']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = None
url = 'https://bugs.python.org/issue44350'
versions = ['Python 3.11']

Linked PRs

@aivarannamaa
Copy link
Mannequin Author

aivarannamaa mannequin commented Jun 8, 2021

Many macOS apps show location info about current document on command-clicking on window title.

I just found out how to do it in Tkinter, so I wanted to share it in case someone wants to add it for IDLE: https://sourceforge.net/p/tcl/mailman/tcl-mac/thread/CAEbkakfc%2B5hUGMyWpjGF2DO7dWOX-3AyR8UOjGfbP8djWWtG-A%40mail.gmail.com/#msg37298382

@aivarannamaa aivarannamaa mannequin added the topic-IDLE label Jun 8, 2021
@aivarannamaa aivarannamaa mannequin changed the title Support Support Command-click on window title on macOS Jun 8, 2021
@aivarannamaa aivarannamaa mannequin assigned terryjreedy Jun 8, 2021
@aivarannamaa aivarannamaa mannequin added the topic-IDLE label Jun 8, 2021
@aivarannamaa aivarannamaa mannequin changed the title Support Support Command-click on window title on macOS Jun 8, 2021
@aivarannamaa aivarannamaa mannequin assigned terryjreedy Jun 8, 2021
@aivarannamaa
Copy link
Mannequin Author

aivarannamaa mannequin commented Jun 8, 2021

In short:

window.wm_attributes("-titlepath", stringContainingTheAbsolutePathOfTheDocument)

Passing empty string as the second argument turned the feature off.

@aivarannamaa aivarannamaa mannequin changed the title Support Command-click on window title on macOS Make IDLE support Command-click on window title on macOS Jun 8, 2021
@aivarannamaa aivarannamaa mannequin changed the title Support Command-click on window title on macOS Make IDLE support Command-click on window title on macOS Jun 8, 2021
@terryjreedy terryjreedy added 3.11 only security fixes OS-mac labels Jun 8, 2021
@terryjreedy terryjreedy changed the title Make IDLE support Command-click on window title on macOS IDLE: support Command-click on window title on macOS Jun 8, 2021
@terryjreedy terryjreedy added 3.11 only security fixes OS-mac labels Jun 8, 2021
@terryjreedy terryjreedy changed the title Make IDLE support Command-click on window title on macOS IDLE: support Command-click on window title on macOS Jun 8, 2021
@terryjreedy
Copy link
Member

Documented as macOS specific at https://www.tcl.tk/man/tcl8.6/TkCmd/wm.htm. But I would not know about C-click from "Specifies the path of the file referenced as the window proxy icon (which can be dragged and dropped in lieu of the file's finder icon). "

IDLE document windows already have the absolute path in the title. There is only an issue if it is too long for the space, such as when editing installed idlelib test files. I don't know what will happen if/when you use tabbed windows.

In the meanwhile, it would be easy to add
if long and sys.platform == 'darwin':
# Only valid as long as 'long' is absolute path.
self.top.wm_attributes("-titlepath", long)
to the end of editor.EditorWindow.saved_change_hook.

Ned or Ronald, is this worth it? Is there any downside to this?

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
@ronaldoussoren
Copy link
Contributor

This is a screenshot of the current behaviour:
Screenshot 2023-12-09 at 10 50 23

This shows that the file name and full path are shown in the window title, but those are not interactive elements.

With the proposed change you get to see:

image

The file icon is an interactive element that can be used to shown the full path to the file, and the icon can also be dragged to locations accepting a file location (shows the full path when dragged into the terminal and can also be used to drag the file into a file open dialog or ...)

image

This is one line change to editor.py, add the following line to the end of "saved_change_hook":

    self.top.wm_attributes("-titlepath", long)

This also works with new files ("File" -> "New File"): This gets shown as "untitled" in the window title and grows the file icon on first save.

This behaviour matches the behaviour of other editor windows on macOS and is IMHO a good new feature.

ronaldoussoren added a commit to ronaldoussoren/cpython that referenced this issue Dec 9, 2023
The platform standard on macOS is to show a proxy icon for open
files in the titlebar of Windows. Make sure IDLE matches this
behaviour.
@ronaldoussoren
Copy link
Contributor

The attached PR does slightly more than just this issue:

  • Use the proxy icon (this issue)
  • Maintain window save state (black dot in the red close icon instead of modifying the window title)
  • Only show the short filename in the title, not the long name as well as the long one can be retrieved from the proxy item. This matches platform behaviour.

This brings the editor window closer to default behaviour. Behaviour is not perfectly aligned with the platform though, see the screenshot below for a native Cocoa window which has a quick edit dropdown for renaming and moving files. AFAIK that's not possible with Tk, but I'm hardly an expert.

image

@ronaldoussoren
Copy link
Contributor

Another thing I ran into is that IDLE will close without warning when there are open unsaved files. I've filed #112898 for that.

@terryjreedy terryjreedy added type-bug An unexpected behavior, bug, or error 3.13 bugs and security fixes and removed 3.11 only security fixes labels Dec 10, 2023
@terryjreedy
Copy link
Member

terryjreedy commented Dec 10, 2023

Ronald, thank you for the images. For once, they are more helpful than text. The phrase 'file-proxy icon' seems macOS specific. Windows has clickable app icons at the left end of the title bar. I had not noticed before the little icons next to some titles on macOS. IDLE on macOS not having them can be seen as a bug, even though clicking will not do the same.

I will experiment with the PR I hope tomorrow. A couple of thoughts: first, there is a tension between cross-platform behavior, which I am in favor of as much as sensibly possible, and platform-specific customization. Second, I hope to eventually switch to a multi-tabbed editor. At that time, tabs will only have short names. Notepad++ on Windows puts the path for the currently active tab on the window title bar. And third, IDLE has (underused) hover tips. I should see if hovering over the title bar can trigger anything. Or ditto for hovering over tabs.

@chrstphrchvz
Copy link
Contributor

chrstphrchvz commented Dec 10, 2023

Behaviour is not perfectly aligned with the platform though, see the screenshot below for a native Cocoa window which has a quick edit dropdown for renaming and moving files. AFAIK that's not possible with Tk, but I'm hardly an expert.

image

That is the “Document Management” feature introduced in OS X 10.9 Mavericks. I believe it is only available in apps using certain AppKit APIs like NSDocument, which Tk Aqua does not and likely will not use.

And third, IDLE has (underused) hover tips. I should see if hovering over the title bar can trigger anything.

The title bar is a decoration provided by the window manager. On X11, Tk toplevels have no awareness of mouse events for window manager decorations, so I believe there is no supported way to detect titlebar hovering. I cannot say that Tk for Win32 or Aqua have strictly conformed to this X11 behavior; however, if some version of Tk for Win32 or Aqua does report e.g. motion events for window decorations or other locations outside of a toplevel, then I believe that is incidental and not a supported feature.

@ronaldoussoren ronaldoussoren added type-feature A feature request or enhancement and removed type-bug An unexpected behavior, bug, or error labels Dec 27, 2023
@terryjreedy
Copy link
Member

terryjreedy commented Feb 3, 2024

To be clearer than I was before, I support adding mac specific things, but I am opposed to removing cross-platform features when that makes IDLE on mac harder to use by a non-Mac user, such as me.

My memory of looking at file-proxy icons on other Mac Catalina apps is that there was hardly consistent behavior, but TextEdit and Script Editor both show the path components after control- or command-click. The problem is discoverability. The IDLE doc should gain an IDLE on Mac section, or maybe 'OS Differences'.

Save state: Neither TextEdit nor Script Editor put a dot in the upper left red close circle. Both add -- edited to the (short) filename. A little black dot does not seem standard, and it might be hard to see, and would not be visible to non-Mac users. Add it but please leave *s.

@ronaldoussoren
Copy link
Contributor

To be clearer than I was before, I support adding mac specific things, but I am opposed to removing cross-platform features when that makes IDLE on mac harder to use by a non-Mac user, such as me.

My memory of looking at file-proxy icons on other Mac Catalina apps is that there was hardly consistent behavior, but TextEdit and Script Editor both show the path components after control- or command-click. The problem is discoverability. The IDLE doc should gain an IDLE on Mac section, or maybe 'OS Differences'.

Save state: Neither TextEdit nor Script Editor put a dot in the upper left red close circle. Both add -- edited to the (short) filename. A little black dot does not seem standard, and it might be hard to see, and would not be visible to non-Mac users. Add it but please leave *s.

I've reverted that part of the change, I agree that keeping them is nicer for cross platform consistency.

Long term it might be nicer to look into using some other way to indicate change (such as one of the unicode bullet characters like ●, possibly with a different colour), but that's for a different issue and would require cross platform testing.

terryjreedy added a commit that referenced this issue Feb 23, 2024
The platform standard on macOS is to show a proxy icon for open
files in the titlebar of Windows. Make sure IDLE matches this
behaviour.

Don't use both the long and short names in the window title.
The behaviour of other editors (such as Text Editor) is to show
only the short name with the proxy icon.

Co-authored-by: Terry Jan Reedy <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Feb 23, 2024
…ythonGH-112894)

The platform standard on macOS is to show a proxy icon for open
files in the titlebar of Windows. Make sure IDLE matches this
behaviour.

Don't use both the long and short names in the window title.
The behaviour of other editors (such as Text Editor) is to show
only the short name with the proxy icon.

(cherry picked from commit b481018)

Co-authored-by: Ronald Oussoren <[email protected]>
Co-authored-by: Terry Jan Reedy <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Feb 23, 2024
…ythonGH-112894)

The platform standard on macOS is to show a proxy icon for open
files in the titlebar of Windows. Make sure IDLE matches this
behaviour.

Don't use both the long and short names in the window title.
The behaviour of other editors (such as Text Editor) is to show
only the short name with the proxy icon.

(cherry picked from commit b481018)

Co-authored-by: Ronald Oussoren <[email protected]>
Co-authored-by: Terry Jan Reedy <[email protected]>
terryjreedy added a commit that referenced this issue Feb 23, 2024
…GH-112894) (#115840)

The platform standard on macOS is to show a proxy icon for open
files in the titlebar of Windows. Make sure IDLE matches this
behaviour.

Don't use both the long and short names in the window title.
The behaviour of other editors (such as Text Editor) is to show
only the short name with the proxy icon.

(cherry picked from commit b481018)

Co-authored-by: Ronald Oussoren <[email protected]>
Co-authored-by: Terry Jan Reedy <[email protected]>
terryjreedy added a commit that referenced this issue Feb 23, 2024
…GH-112894) (#115841)

The platform standard on macOS is to show a proxy icon for open
files in the titlebar of Windows. Make sure IDLE matches this
behaviour.

Don't use both the long and short names in the window title.
The behaviour of other editors (such as Text Editor) is to show
only the short name with the proxy icon.

(cherry picked from commit b481018)

Co-authored-by: Ronald Oussoren <[email protected]>
Co-authored-by: Terry Jan Reedy <[email protected]>
smontanaro pushed a commit to smontanaro/cpython that referenced this issue Feb 23, 2024
… macOS (pythonGH-112894)

The platform standard on macOS is to show a proxy icon for open
files in the titlebar of Windows. Make sure IDLE matches this
behaviour.

Don't use both the long and short names in the window title.
The behaviour of other editors (such as Text Editor) is to show
only the short name with the proxy icon.

(cherry picked from commit b481018)

Co-authored-by: Ronald Oussoren <[email protected]>
Co-authored-by: Terry Jan Reedy <[email protected]>
woodruffw pushed a commit to woodruffw-forks/cpython that referenced this issue Mar 4, 2024
…ython#112894)

The platform standard on macOS is to show a proxy icon for open
files in the titlebar of Windows. Make sure IDLE matches this
behaviour.

Don't use both the long and short names in the window title.
The behaviour of other editors (such as Text Editor) is to show
only the short name with the proxy icon.

Co-authored-by: Terry Jan Reedy <[email protected]>
diegorusso pushed a commit to diegorusso/cpython that referenced this issue Apr 17, 2024
…ython#112894)

The platform standard on macOS is to show a proxy icon for open
files in the titlebar of Windows. Make sure IDLE matches this
behaviour.

Don't use both the long and short names in the window title.
The behaviour of other editors (such as Text Editor) is to show
only the short name with the proxy icon.

Co-authored-by: Terry Jan Reedy <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.13 bugs and security fixes OS-mac topic-IDLE type-feature A feature request or enhancement
Projects
Status: Done
Development

No branches or pull requests

3 participants