VLWEB Color picker

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
soa
Posts: 339
Joined: Mon Dec 07, 2015 3:15 pm

VLWEB Color picker

Post 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
GregSippel
Posts: 25
Joined: Thu May 19, 2016 11:34 am

Re: VLWEB Color picker

Post 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
soa
Posts: 339
Joined: Mon Dec 07, 2015 3:15 pm

Re: VLWEB Color picker

Post 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
soa
Posts: 339
Joined: Mon Dec 07, 2015 3:15 pm

Re: VLWEB Color picker

Post 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
jyoung
Posts: 694
Joined: Thu Jan 21, 2016 6:43 am
Location: Oklahoma City, OK USA

Re: VLWEB Color picker

Post by jyoung »

Check the id attribute

Code: Select all

colorPicker.Id = "cpick"; 
It looks like you have a capital "I" in Id.

Try using a lowercase id

Code: Select all

colorPicker.id = "cpick";
- Joe
dannyoorburg
Posts: 177
Joined: Mon Jan 04, 2016 9:50 am
Location: Australia

Re: VLWEB Color picker

Post 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
Post Reply