Hi,
I'm playing with custom controls, this sample shows how to move squares in an image. The only way to force redraw I found is to hide then to show the control. Is there a nicer solution ?
var myWindow = new Window ("dialog", "Draw squares");
myWindow.add ("button",undefined,"cancel")
var CompoPreview = myWindow.add ("image", undefined)
CompoPreview.size = [200,200];
CompoPreview.onDraw = generatePreviewPhoto
var myEvent = new UIEvent("resize");
var MySlider = myWindow.add ("slider", undefined, 50, 0, 100);
var coef=MySlider.value
MySlider.onChanging = function ()
{
coef = this.value;
CompoPreview.hide()
CompoPreview.show()
}
function generatePreviewPhoto(){
var x,y,l,h,idx,gl;
nbPhotos = 5;
for (idx=0;idx < nbPhotos;idx++)
{
y = x = idx*coef ;
l= 30;
h= 30;
gl = 1-idx/(nbPhotos-1);
this.graphics.newPath();
this.graphics.rectPath(x,y,l,h);
this.fillBrush = this.graphics.newBrush( this.graphics.BrushType.SOLID_COLOR,[gl,gl,gl,1] );
this.graphics.fillPath(this.fillBrush);
}
}
myWindow.show ();