Tk Source Code

View Ticket
Ticket UUID: de0c219db21a71466283f7bb87dad4cb55346c48
Title: Use platform placeholder text colors as defaults
Type: RFE Version: 8.7
Submitter: chrstphrchvz Created on: 2020-07-14 10:23:30
Subsystem: 07. [entry] Assigned To: fvogel
Priority: 5 Medium Severity: Cosmetic
Status: Closed Last Modified: 2020-08-24 13:06:38
Resolution: Fixed Closed By: fvogel
    Closed on: 2020-08-24 13:06:38

TIP #496 ([11fcd2c708]) added support for placeholder text in Entry widgets. The default -placeholderforeground is currently specified as #b3b3b3 (gray70) for all platforms. However, some platforms already provide a specific system color that should be used for this purpose. On macOS 10.10 and later, this is placeholderTextColor. There may be a similar system color on Windows, however I'm not sure there is a more specific one to use than COLOR_GRAYTEXT.

User Comments: fvogel added on 2020-08-24 13:06:38:
Merged into trunk.

fvogel added on 2020-08-15 07:45:59:

A few further commits later (to make use of the updated mac color files - thanks Marc!, and to update the documentation), I believe this rfe branch is ready to be merged into trunk.

I will proceed soon, unless new comments gets submitted.

fvogel added on 2020-07-14 21:54:07:
Now done (both the revert and the ttk widgets adaptation). Please see the rfe branch.

Comments? Thanks!

fvogel added on 2020-07-14 21:13:49:

Indeed. I have reworked this, see the rfe branch. I have updated the documentation as well.

I tried to use the same color name on Windows as on macOS. This led to name this color systemPlaceholderTextColor on both platforms, which is slightly inconsistent with how colors are named on Windows (it would rather have been systemPlaceholderText on Win). Not fully sure what is the right thing to do here, I will probably revert to systemPlaceholderText on Win after all.

There is still the ttk::entry widget to deal with.

chrstphrchvz added on 2020-07-14 17:11:57:

Sorry for the confusion: I had referred to the system colors as named by platforms' APIs; they need to first be defined in tkWinColor.c, tkMacOSXColor.c, etc., before they're ready to be used in tkWinDefault.h, tkMacOSXDefault.h, etc.

So on Aqua, the color would likely be named "systemPlaceholderTextColor". (This could be safely done for 8.6 though it would be unused.) tkMacOSXColor.c is also where compatibility with older systems would be handled: on 10.9 and earlier there is NSColor grayColor. Or possibly there is another close-enough system color (one that Tk might already be using).

I also do not currently know if there is a better alternative for X11.

fvogel added on 2020-07-14 16:34:10:

Thanks for making this observation. I have committed the change you suggest in [5fc386f85b].

A few remarks/questions:

  • I could test on Windows: COLOR_GRAYTEXT is very close (if not identical) to the previous default #b3b3b3 (gray70). Fine.
  • I could not test on the mac because my remote access to a mac is currently broken. Can you try perhaps?
  • On the mac #b3b3b3 is still used as default for macOS versions before 10.10. Are you aware of a better choice?
  • On Linux I made no change and kept #b3b3b3 since I could not find anything relevant on the subject on the internet.