Page 1 of 1
VLWEB Color picker
Posted: Wed Apr 11, 2018 12:05 pm
by soa
Unlike VL for Windows VLWEB has no color picker control. I imagine that this can be provided using a widget around a JavaScript control. Has anyone done this or can recommend a good (touch friendly) control.
Cheers
Jim
Re: VLWEB Color picker
Posted: Fri Apr 13, 2018 8:44 am
by GregSippel
Soa,
A simple widget that uses an input of type equals "color" is what you need, See
https://developer.mozilla.org/en-US/doc ... nput/color
Note, while it will work in all browsers it will look different in all browsers.
Cheers
Greg
Re: VLWEB Color picker
Posted: Fri Apr 13, 2018 9:01 am
by soa
Greg
That looks pretty good. This needs to work on an ipad and its not clear from googling that it does. I'll give it a go.
Cheers
Jim
Re: VLWEB Color picker
Posted: Fri Apr 13, 2018 10:26 am
by soa
making good progress but need a little help;
1 I'm creating the input element thus
var colorPicker = document.createElement("input");
colorPicker.type = "color";
colorPicker.Id = "cpick";
parentDiv.appendChild(colorPicker);
colorPicker.addEventListener("change",colourUpdated, false);
and its working and I'm getting events.
but I need to set the colour so I have:
PROTOTYPE.SetColour = function( strNewColour )
{
var cpick = document.getElementById("cpick");
cpick.value = strNewColour;
// Implementation...
}
but this crashes with 'cannot set the value of null';
Any ideas?
Cheers
Jim
Re: VLWEB Color picker
Posted: Sat Apr 14, 2018 12:21 am
by jyoung
Check the id attribute
It looks like you have a capital "I" in Id.
Try using a lowercase id
- Joe
Re: VLWEB Color picker
Posted: Sat Apr 14, 2018 7:32 am
by dannyoorburg
It's easiest to just keep a reference to the element..
this.colorPicker = document.createElement("input");
this.colorPicker.type = "color";
And then just say
this.colorPicker.value = strNewColour;
This way of coding also allows you to create multiple instances of a widget.....
Danny