Recent

Author Topic: Memo highlighting colour & contrast issue  (Read 613 times)

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1046
  • Former Delphi 1-7, 10.2 User
Memo highlighting colour & contrast issue
« on: June 30, 2019, 05:48:17 am »
When highlighting a search hit in a memo, rather than the usual light blue highlight colour, the highlight is colour light grey. This is just usable in light mode on macOS, but in dark mode the highlighting simply disappears into the background.

Attachment 1: light mode
Attachment2: dark mode

Can the colour of the highlighting be changed?
o Lazarus v2.1.0 r63871, FPC v3.3.1 r47164, macOS 10.14.6 (with sup update), Xcode 11.3.1
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.1 amd64 (VMware Fusion VM)
o FPC 3.0.4, FreeBSD 12.2-STABLE r365646 amd64
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 20.04 (Parallels VM)

lucamar

  • Hero Member
  • *****
  • Posts: 3179
Re: Memo highlighting colour & contrast issue
« Reply #1 on: June 30, 2019, 06:04:42 am »
It is not exactly that the "highlight"-color changes but that the memo is not the focused control.

When an edit control (or, in fact, most controls) goes out of focus the color of the selection is "washed out" as a visual cue. This happens in virtuallly all OS/WM combinations.

You can test this yourself: simply <TAB> back and forth from the edit control to the memo to see the selection's color change.

AFAIK the only way to avoid it is to modify the Window Manager theme by hand, which I don't know how is done in MacOS, but I suppose you do?
« Last Edit: June 30, 2019, 06:06:40 am by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.10/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1046
  • Former Delphi 1-7, 10.2 User
Re: Memo highlighting colour & contrast issue
« Reply #2 on: June 30, 2019, 06:25:31 am »
Curiously it doesn't happen in Windows 7 or 10 (same code) -- see attachment.

It also didn't happen in the old Delphi 10.2.1 version of my program in Windows or macOS which led me to believe it was Lazarus/FPC thing and possibly related to the Cocoa widget set because it doesn't happen in Windows with the win32 widget set.

Quote
You can test this yourself: simply <TAB> back and forth from the edit control to the memo to see the selection's color change.

Yep, I noticed that.

Quote
AFAIK the only way to avoid it is to modify the Window Manager theme by hand, which I don't know how is done in MacOS, but I suppose you do?

Alas, I don't. However, it just occurred to me that maybe I can get away with leaving the focus on the memo and capturing the keystrokes, filling in the search edit and all will be well. Hmmm.
o Lazarus v2.1.0 r63871, FPC v3.3.1 r47164, macOS 10.14.6 (with sup update), Xcode 11.3.1
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.1 amd64 (VMware Fusion VM)
o FPC 3.0.4, FreeBSD 12.2-STABLE r365646 amd64
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 20.04 (Parallels VM)

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2532
    • havefunsoft.com
Re: Memo highlighting colour & contrast issue
« Reply #3 on: June 30, 2019, 06:29:57 am »
When highlighting a search hit in a memo, rather than the usual light blue highlight colour, the highlight is colour light grey. This is just usable in light mode on macOS, but in dark mode the highlighting simply disappears into the background.
This is by Apple design. Cocoa widgetset doesn't modify the selection color in anyway.
In your case the issue is seen when TMemo doesn't have a focus.

Try the following - start Apple's TextEdit, paste the same text and you have on the screenshot.
Select the text (note that "focused" control selection is blueish)
and then click away from TextEdit (to make it non focused window).
You should see that Apple's TextEdit selection color is exactly the same as TMemo's color.

Can the colour of the highlighting be changed?
The answer is maybe. There are some methods in NStextView that could be overridden or property to be changed (i.e. https://developer.apple.com/documentation/appkit/nstextview/3237223-usesadaptivecolormappingfordarka?language=objc)
In the end, even there's a solution, it would be macOS specific.
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

lucamar

  • Hero Member
  • *****
  • Posts: 3179
Re: Memo highlighting colour & contrast issue
« Reply #4 on: June 30, 2019, 06:33:41 am »
[..] it just occurred to me that maybe I can get away with leaving the focus on the memo and capturing the keystrokes, filling in the search edit and all will be well. Hmmm.

That is ... not recommended. Instead, move the focus back to the memo after setting the selection. To keep on searching just add a handler for the memo's OnKeyUp event capturing F3 or whatever key(s) and, if needed (v.g. to start a new search) moving the focus again to the TEdit.

Curiously it doesn't happen in Windows 7 or 10 (same code) -- see attachment.

[...] it doesn't happen in Windows with the win32 widget set.

Hmm ... you may be right. IIRC Windows just does an all-or-nothing when the control is not focused (depending on some option whose name scapes me ATM): either shows the selection normally or not at all. Linux WMs, on the other hand, act like MacOS in this respect.
« Last Edit: June 30, 2019, 06:39:23 am by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.10/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1046
  • Former Delphi 1-7, 10.2 User
Re: Memo highlighting colour & contrast issue
« Reply #5 on: June 30, 2019, 06:53:10 am »
Thanks Dmitry and lucamar. I'll look into my options.
o Lazarus v2.1.0 r63871, FPC v3.3.1 r47164, macOS 10.14.6 (with sup update), Xcode 11.3.1
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.1 amd64 (VMware Fusion VM)
o FPC 3.0.4, FreeBSD 12.2-STABLE r365646 amd64
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 20.04 (Parallels VM)

 

TinyPortal © 2005-2018