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

Interactive button script

Participant ,
Jan 15, 2024 Jan 15, 2024

hello everyone, how can I write the code part of a script that replaces the text inside an interactive button?

Below is an example on how to change the content of a textframe, but for buttons? I see from the Layer tab that they have a subgroup enclosed in square brackets [Normal].

 

var casellaTesto = documentoAperto.pages[0].textFrames.itemByName("casellaDescrizione");

var newContents = "nuvo testo";

if (casellaTesto.isValid && casellaTesto.contents.length > 0) {
casellaTesto.contents = newContents;
}
TOPICS
Scripting
199
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

Participant , Jan 15, 2024 Jan 15, 2024

I should have found the solution, I attach it.

var stati = [
    "Normale",
    "Rollover",
    "Clic"
    ];


for(i =0;i<stati.length;i++){
    var statoDesiderato = pulsanteXX.states.itemByName(stati[i]);
    if(statoDesiderato){
        statoDesiderato.active = true;
        var textFrameXX = pulsanteXX.allPageItems[1];
        textFrameXX.contents = "test";
    }
}

 

Translate
Participant ,
Jan 15, 2024 Jan 15, 2024

I found out how to rename the text in the button, but it only performs the change on one state of the button, how can I do it on all?
Here are the states of the button
$$$/StateType/Normal
$$$/StateType/Over
$$$/StateType/Down

 

var pulsanteXX = doc.buttons.itemByName("LINGUA");
var textFrame = pulsanteXX.allPageItems[1];
textFrame.contents = "test";

 

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
Participant ,
Jan 15, 2024 Jan 15, 2024
LATEST

I should have found the solution, I attach it.

var stati = [
    "Normale",
    "Rollover",
    "Clic"
    ];


for(i =0;i<stati.length;i++){
    var statoDesiderato = pulsanteXX.states.itemByName(stati[i]);
    if(statoDesiderato){
        statoDesiderato.active = true;
        var textFrameXX = pulsanteXX.allPageItems[1];
        textFrameXX.contents = "test";
    }
}

 

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