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

Making a preview of an image switch?

Advisor ,
May 10, 2016 May 10, 2016

I'm wanting the Pic to change depending on what Radio button i have selected.  Is this possible with Indesign scripting?

  1. // How can i make PreV1 activate the below Radio buttons?  Maybe gray out the Buttons when not the Check box is not checked. 
  2.       
  3.             var PreV1= w.tabs[2].add ('checkbox {text: "To Preview Changes"}'); 
  4.             var Pan1=w.tabs[2].add ('panel {text: "", preferredSize: [-1, 200],orientation: "column",alignChildren: ["left","top"]}'); 
  5.            
  6. // Is there a way to make each radio button display a Different Pictrue?         
  7.       
  8.                     Pan1.add('radioButton {text: "B1.   Enter Here1"}'); 
  9.                     Pan1.add('radioButton {text: "B2.   Enter Here2"}'); 
  10.                     Pan1.add('radioButton {text: "B3.   Enter Here3"}'); 
  11.                     Pan1.add('radioButton {text: "B4.   Enter Here4"}'); 
  12.                     Pan1.add('radioButton {text: "B1.   Enter Here5"}'); 
  13.                     Pan1.add('radioButton {text: "B2.   Enter Here6"}'); 
  14.                     Pan1.add('radioButton {text: "B3.   Enter Here7"}'); 
  15.                     Pan1.add('radioButton {text: "B4.   Enter Here8"}'); 
  16.        
  17.       
  18.                Image.prototype.onDraw =function() 
  19.                 { 
  20.                 if(!this.image )return
  21.                 var WH =this.size,wh   =this.image.size,k   = Math.min(WH[0]/wh[0], WH[1]/wh[1]), xy; 
  22.                   wh   =[k*wh[0],k*wh[1]]; 
  23.                   xy   =[(WH[0]-wh[0])/2, (WH[1]-wh[1])/2 ]; 
  24.                 this.graphics.drawImage(this.image,xy[0],xy[1],wh[0],wh[1]); 
  25.                    WH   = wh = xy =null; 
  26.                 } 
  27.                flower=w.tabs[2].add ("image", undefined, File ("~/\Desktop/\xxx.jpg")); 
  28.                flower.size =[300,300]; 
  29.          
  30.         for( 
  31.         var i = 0
  32.          i < w.tabs.length; 
  33.          i++){ 
  34.         w.tabs.orientation ='column'; 
  35.         w.tabs.alignChildren ='fill'; 
  36.         w.tabs.alignment =['fill','fill']; 
  37.         w.tabs.visible =false; 
  38.         } 
  39.         w.stubs.onChange  = showTab; 
  40.         function 
  41.          showTab () 
  42.         { 
  43.         if(w.stubs.selection !==null){for(var i = w.tabs.length-1; i >= 0
  44.          i--) 
  45.          {     
  46.              w.tabs.visible =false; 
  47.         } 
  48.                  w.tabs[w.stubs.selection.index].visible =true; 
  49.         } 
  50.         } 
  51.           w.onShow  =function() 
  52.         { 
  53.         w.stubs.selection  = 1; 
  54.         showTab; 
  55.         } 
  56.       
  57.       
  58.     myResult = w.show();  
TOPICS
Scripting
941
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

correct answers 1 Correct answer

Guide , May 10, 2016 May 10, 2016
Translate
Advisor ,
May 10, 2016 May 10, 2016

am i on the right path?  I turned off the lower radio buttons to give me more room to play with.

  radioButton = Pan1.add ('radioButton {text: "Pic1"}') 

  1.                 Image.prototype.onDraw =function(){ 
  2.                 if(!this.image )return
  3.                 var WH =this.size,wh   =this.image.size,k   = Math.min(WH[0]/wh[0], WH[1]/wh[1]), xy; 
  4.                   wh   =[k*wh[0],k*wh[1]]; 
  5.                   xy   =[(WH[0]-wh[0])/2, (WH[1]-wh[1])/2 ]; 
  6.                 this.graphics.drawImage(this.image,xy[0],xy[1],wh[0],wh[1]); 
  7.                    WH   = wh = xy =null;} 
        1. flower=w.tabs[2].add ("image", undefined, File ("~/\Desktop/\xxx.jpg"));
  8.                    flower.size =[300,300]; 
  9. /*
  10.                     Pan1.add('radioButton {text: "B2.   Enter Here2"}');
  11.                     Pan1.add('radioButton {text: "B3.   Enter Here3"}');
  12.                     Pan1.add('radioButton {text: "B4.   Enter Here4"}');
  13.                     Pan1.add('radioButton {text: "B1.   Enter Here5"}');
  14.                     Pan1.add('radioButton {text: "B2.   Enter Here6"}');
  15.                     Pan1.add('radioButton {text: "B3.   Enter Here7"}');
  16.                     Pan1.add('radioButton {text: "B4.   Enter Here8"}');
  17. */         
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
Advisor ,
May 10, 2016 May 10, 2016

I should mention that this preview will be on the UI of my script.

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
Guide ,
May 10, 2016 May 10, 2016
LATEST
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