need to retrieve color from color well

G’day scripters

I’m trying to use a color picker to set the color of text in an email, but can’t for the life of me work out how to retrieve the color of the color well.

Could someone point me in the right direction please, cause everything I’ve tried has crashed

Regards

Santa

set TheColor to MainColorWell's color
			

Edit.

Even this errors out with a ‘variable has no value’ error. What the heck am I doing wrong?



on colorWellSet_(sender)
		try
			set ThetempColor to MainColorWell's getComponents_()
			display dialog ThetempColor as text
		on error errmsg
			display dialog errmsg
		end try
	end colorWellSet_

What happens if you replace display dialog with log, what is in the log then.

G’day Richard.

Here’s the log

16/11/09 10:13:58 AM Mail Manager Reporter[953] *** -[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class (SketchUpColor)
16/11/09 10:14:01 AM Mail Manager Reporter[953] <Mail_Manager_ReporterAppDelegate @0x2007d3aa0: OSAID(4)>
16/11/09 10:14:01 AM Mail Manager Reporter[953] -[NSColorWell getComponents:]: unrecognized selector sent to instance 0x2007927a0
16/11/09 10:14:09 AM Mail Manager Reporter[953] <Mail_Manager_ReporterAppDelegate @0x2007d3aa0: OSAID(4)>
16/11/09 10:14:09 AM Mail Manager Reporter[953] -[NSColorWell getComponents:]: unrecognized selector sent to instance 0x2007927a0
16/11/09 10:14:15 AM Mail Manager Reporter[953] *** -[Mail_Manager_ReporterAppDelegate colorWellSet:]: User canceled. (error -128)

Also, if I try and put brackets () behind the word ‘color’ they get changed to {}

Regards

Santa

Can I see the log using this:


on colorWellSet_(sender)
		try
			log 1
			set ThetempColor to MainColorWell's getComponents_()
			log 2
			log ThetempColor as text
			log 3
		on error errmsg
			log 4
			log errmsg
			log 5
		end try
	end colorWellSet_

This method hasn’t failed me yet, I know which error is which.

G’day

16/11/09 10:40:30 AM Mail Manager Reporter[1170] *** -[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class (SketchUpColor)
16/11/09 10:40:32 AM Mail Manager Reporter[1170] 1
16/11/09 10:40:32 AM Mail Manager Reporter[1170] -[NSColorWell getComponents:]: unrecognized selector sent to instance 0x2007b55e0
16/11/09 10:40:32 AM Mail Manager Reporter[1170] 4
16/11/09 10:40:32 AM Mail Manager Reporter[1170] -[NSColorWell getComponents:]: unrecognized selector sent to instance 0x2007b55e0
16/11/09 10:40:32 AM Mail Manager Reporter[1170] 5

G’day again

If i force the code to accept the word color with

set ThetempColor to theMainColorWell’s |color|()

then the log becomes…

16/11/09 10:44:58 AM Mail Manager Reporter[1192] *** -[NSKeyedUnarchiver decodeObjectForKey:]: cannot decode object of class (SketchUpColor)
16/11/09 10:45:00 AM Mail Manager Reporter[1192] 1
16/11/09 10:45:00 AM Mail Manager Reporter[1192] 2
16/11/09 10:45:00 AM Mail Manager Reporter[1192] 4
16/11/09 10:45:00 AM Mail Manager Reporter[1192] Can’t make «class ocid» id «data kptr0000000040144B0002000000» into type text.
16/11/09 10:45:00 AM Mail Manager Reporter[1192] 5

G’day

I’m getting somewhere, but not sure what to do next. Is anyone able to tell me what to do with it now please?

Regards

Santa

Using


on colorWellSet_(sender)
		try
			log 1
			set ThetempColor to theMainColorWell's |color|
			log 2
			log ThetempColor
			log 3
		on error errmsg
			log 4
			log errmsg
			log 5
		end try
	end colorWellSet_

returns

16/11/09 12:40:56 PM Mail Manager Reporter[1553] 1
16/11/09 12:40:56 PM Mail Manager Reporter[1553] 2
16/11/09 12:40:56 PM Mail Manager Reporter[1553] NSCalibratedRGBColorSpace 1 0.980652 0.0472207 1
16/11/09 12:40:56 PM Mail Manager Reporter[1553] 3

In the logs before last it is weird you have an error before 1, something is wrong besides the code you’ve shown me, possibly the well itself, what’s even weirder is removing the brackets fixed it so I bet it was something else you did. What is this handler activated by exactly?

G’day Richard, & thanks for your advice. If it wasn’t for logging it I wouldn’t have fixed it.

Turned out using color() was crashing cause…

  1. it didn’t need brackets
    2, it was clashing with the use of ‘color’ in the mail handling part of my script, which couldn’t be changed.

So, here tis’…


on colorWellSet_(sender)
		try
			set ThetempColor to theMainColorWell's |color|
			set temp1 to ThetempColor's redComponent()
			set temp2 to ThetempColor's greenComponent()
			set temp3 to ThetempColor's blueComponent()
			set TheColor to {(temp1 * 65535), (temp2 * 65535), (temp3 * 65535)}
		on error errmsg
			display dialog errmsg
		end try
	end colorWellSet_