• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Programmatically toggle display to white on black
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Programmatically toggle display to white on black


  • Subject: Re: Programmatically toggle display to white on black
  • From: Philip Dow <email@hidden>
  • Date: Mon, 26 Jun 2006 23:16:03 +0200

If you are in full-screen mode, can't you control the text colors normally, without resorting to a trick like this?

That was the original plan, but then the text includes embedded elements, various fonts and graphics. I'm not working with a pure string that I could just dump into a text view and the set the color on it. Additionally, it's not just for text editing. A click on a web link for example would bring up the program's embedded web browser, and I would like that to work in the low light conditions as well. As for the trick, trust me, if I knew of an API I would use it.


And if the user normally runs in white-on-black mode, this will do the opposite of what you want.

I will not toggle the display automatically on any occasion. That is completely up the user. Now, if the *user* wants to do the opposite of what he or she wants, then, well, whatever I guess. But if the display is already in this mode, I think they'll be able to figure it out.


If the app dies unexpectedly while in this mode, most users won't know how to bring things back to normal.

I think this is the most valid concern. But because the user will have manually toggled the display into inverted mode, I hope they will know enough that running the same command will toggle it back out, as it would function normally.


-Phil

On Jun 26, 2006, at 7:20 PM, John Stiles wrote:

If you are in full-screen mode, can't you control the text colors normally, without resorting to a trick like this? If the app dies unexpectedly while in this mode, most users won't know how to bring things back to normal. And if the user normally runs in white-on- black mode, this will do the opposite of what you want.


On Jun 26, 2006, at 10:08 AM, Philip Dow wrote:

This will be under the control of the user. It is for use in full screen text editing mode under low light conditions.

The trick is as follows:

CGPostKeyboardEvent((CGCharCode)0, (CGKeyCode)55, true); // command
CGPostKeyboardEvent((CGCharCode)0, (CGKeyCode)58, true); // option
CGPostKeyboardEvent((CGCharCode)0, (CGKeyCode)59, true); // ctrl


CGPostKeyboardEvent((CGCharCode)0, (CGKeyCode)28, true); // number 8 CGPostKeyboardEvent((CGCharCode)0, (CGKeyCode)28, false); CGPostKeyboardEvent((CGCharCode)0, (CGKeyCode)59, false); CGPostKeyboardEvent((CGCharCode)0, (CGKeyCode)58, false); CGPostKeyboardEvent((CGCharCode)0, (CGKeyCode)55, false);

Apple documentation specifically warns against using this method and instead recommends CGCreateKeyboardEvent. That method crashes every time as I call it so I'm not bothering with it. Applescript was also an option:

tell application "System Events"
	tell application process "MyHappyProcess"
		key code 28 using {command down, option down, control down}
	end tell
end tell

-Phil

On Jun 26, 2006, at 4:01 PM, Scott Thompson wrote:


On Jun 24, 2006, at 12:53 PM, Philip Dow wrote:

Is anyone aware of a way to switch the display into white on black mode then eventually back? This is a feature available via Universal Access that I would like to use programatically.

I've searched through the CGDisplay docs, Quartz stuff, NSScreen, -Display and -ColorSpace but haven't found anything. Cocoadev doesn't seem to have anything on the topic and the Apple lists only produced an unanswered request from 2003.

I'd be fine with sending a command-alt-ctrl-8 keyboard shortcut event to the system, but I don't know how to do this either.

As a general rule, this is something that should be under the control of the user, and the operating system. You might explain a bit more why you want to do this from your application. Are you creating some kind of assistive device?


Scott



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40blizzard.com


This email sent to email@hidden



_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Programmatically toggle display to white on black (From: Philip Dow <email@hidden>)
 >Re: Programmatically toggle display to white on black (From: Scott Thompson <email@hidden>)
 >Re: Programmatically toggle display to white on black (From: Philip Dow <email@hidden>)
 >Re: Programmatically toggle display to white on black (From: John Stiles <email@hidden>)

  • Prev by Date: Why doesn't placeholder string draw in NSTextField?
  • Next by Date: Re: Detecting Internet
  • Previous by thread: Re: Programmatically toggle display to white on black
  • Next by thread: Folder Action the Cocoa Way
  • Index(es):
    • Date
    • Thread