Web color picker

Has anyone created a Xojo web color picker by any chance? (unfortunately, SelectColor doesn’t work) I’m about to code one and then wondered if I was re-creating the wheel. I’m not looking for anything complex, maybe 16+ colors or so.

Taylor Design has one: http://webcustomcontrols.com
Jeremie Leroy has one: http://www.jeremieleroy.com/products/web-bundle.php#colorpicker

Thanks, Bob. I was wondering if anyone had rolled their own on this one. Taylor’s is based on the Yahoo interface and Jeremie Leroy is not known for rapid customer support (I purchased his software and never got it activated).

I will probably cobble together something simple that converts 16 or maybe 64 rectangles into their hex equivalents. I was just hoping to save an afternoon’s work if someone had already done it.

BTW, with your help and help from the folks at Xojo, my app is up and running without incident and processing a couple of hundred exams a day!

It is relatively easy to use MouseDown over a picture of the color picker and use Picture.Graphics.Pixel to get the color under the click. Then a simple str(color) and a replace will get you the # value.

Just lift the color circle from the Desktop one with a screen grab.

Does that work for web apps? I’ve tried it already using a canvas that has a picture assigned to it, but the web canvas doesn’t have a graphics property.

this is what I tried:

Dim c as Color
c = cvsColor.Graphics.Pixel(x, y)

but I couldn’t get that to work.

[quote=233663:@Peter Stallo]Does that work for web apps? I’ve tried it already using a canvas that has a picture assigned to it, but the web canvas doesn’t have a graphics property.

this is what I tried:

Dim c as Color
c = cvsColor.Graphics.Pixel(x, y)

but I couldn’t get that to work.[/quote]
Web canvas does have a paint event though.

Here is a very basic example :

  • Display the Xojo color picker (insert color).
  • Grab the screen (shift-Command-4 in Mac, Alt-PrtSc in Windows), save the color circle as a picture. I used the name colorpicker.png
  • Drag colorpicker.png in the project
  • Add a p as picture property to the webpage
  • Add a Rectangle next to the
  • Drag a WebImageView (Image Well) onto the webpage.
  • Make colorpicker its picture property

In the WebImageView Open :

Sub Open() p = colorpicker End Sub

In the MouseDown :

[code]Sub MouseDown(X As Integer, Y As Integer, Details As REALbasic.MouseEvent)
system.DebugLog str(p.Graphics.pixel(x,y))

dim js as string
js = “document.getElementById(’”+Rectangle1.ControlID+"’).style.backgroundColor=’#"+right(str(p.Graphics.pixel(x,y)),6)+"’;"
self.ExecuteJavaScript(js)

End Sub[/code]

When a color is clicked in the circle, it is displayed in the messages section of the IDE, as well as applied to the rectangle by the JavaScript.

Brilliant! That worked!