Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Method to dynamically change an image in scriptUI

Community Beginner ,
May 02, 2008 May 02, 2008
I'm trying to run before I can walk, but:

Is there any way to respond to a click on an image in a dialog created with scriptUI?

I want to modify which image is shown during the user's interaction with the dialog. I think that the "stack" method will create a stack of more than 32 layers, so it would be tidier to be able to just modify an instance of the image each time.

I may also want to dynamically add more images during dialog, and therefore need to be able to resize the panel in the dialog window.




var myIcons = new Array();
myIcons[0] = "/path...to/image1.png";
myIcons[1] = "/path...to/image2.png";
var myPanel;
myPanel = myCreatePanel();
myPanel.show();
myIncrement=1;
for(var myCounter = 0; myCounter < 11; myCounter ++){
$.sleep (100);
}
myPanel.hide();
exit();

function myCreatePanel(){
myPanel = new Window('palette', 'test bed');
with(myPanel){
myPanel.myButton = add('image', undefined, myIcons[0]);
myPanel.myButton.addEventListener('click', updateIcon);
}
return myPanel;
}

function updateIcon() {
iconShow +=1; if (iconShow = 2){iconShow = 0};
myPanel.myButton.image = myIcons[iconShow];
}



Any hints and help much appreciated...

Thanks,
Jezz
TOPICS
Scripting
1.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 03, 2008 May 03, 2008
I'm hacking out some code, and making some degree of progress... I'll post the results once it's tidy!

--Jezz
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 08, 2009 Dec 08, 2009

Did you ever come up with a solution for this? Thanks!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Jul 13, 2016 Jul 13, 2016
LATEST

I was having to do this and ended up using the remove() method on my image's parent to remove it, and then add a new image with a different file. Then I called the window.layout.layout(true) to force an update on the window that shows the new added image.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines