Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


How to let user come back to the Interface (Script UI) ?

Enthusiast ,
May 01, 2021 May 01, 2021

Copy link to clipboard

Copied

Hi Experts..

I Wonder if the user make bad input and i want the script not to continue and let him stay in the Script UI to re-enter correct data, like if i want the user to enter only numbers! and he enter alphabet chars in the edit text field, so if the user hit ok i want to alert him and make him stay back in Script UI Until he enter correct entries

 

//Check User Input in Edittext
function CheckUserInput () {
if (isNaN(Number(myNum.text))) {
alert("Are you Kidding! , Only numbers Accepted!", "Kidding User!");
return PleaseReSelect(); //here i want the user to go back to Script UI
} else {
    StartPNumbering(); //here the Script will continue
  }    
}

 

Thanks in Advance

Best

M.Hasanain

Best
M.Hasanain
TOPICS
Scripting

Views

109

Likes

Translate

Translate

Report

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

Advocate , May 01, 2021 May 01, 2021
Hello, see the sample code below, this code only allows digits to be entered in the edit text box by adding a Event Listener.......// DIALOG // ====== var dialog = new Window("dialog"); dialog.text = "Match Object & Move"; dialog.preferredSize.width = 300; dialog.preferredSize.height = 300; dialog.orientation = "column"; dialog.alignChildren = ["center","top"]; dialog.spacing = 10; dialog.margins = 16; // GROUP1 // ====== var group1 = dialog.add("group", unde...

Likes

Translate

Translate
Advocate ,
May 01, 2021 May 01, 2021

Copy link to clipboard

Copied

Hello,

 

see the sample code below, this code only allows digits to be entered in the edit text box by adding a Event Listener.......

// DIALOG
// ======
var dialog = new Window("dialog"); 
    dialog.text = "Match Object & Move"; 
    dialog.preferredSize.width = 300; 
    dialog.preferredSize.height = 300; 
    dialog.orientation = "column"; 
    dialog.alignChildren = ["center","top"]; 
    dialog.spacing = 10; 
    dialog.margins = 16; 

// GROUP1
// ======
var group1 = dialog.add("group", undefined, {name: "group1"}); 
    group1.preferredSize.width = 270; 
    group1.orientation = "row"; 
    group1.alignChildren = ["left","center"]; 
    group1.spacing = 10; 
    group1.margins = [0,0,0,11]; 

var statictext1 = group1.add("statictext", undefined, undefined, {name: "statictext1"}); 
    statictext1.text = "Find Object with specific value & change"; 

// PANEL1
// ======
var panel1 = dialog.add("panel", undefined, undefined, {name: "panel1"}); 
    panel1.text = "Match Object"; 
    panel1.preferredSize.width = 270; 
    panel1.preferredSize.height = 100; 
    panel1.orientation = "column"; 
    panel1.alignChildren = ["left","top"]; 
    panel1.spacing = 10; 
    panel1.margins = 10; 

// GROUP2
// ======
var group2 = panel1.add("group", undefined, {name: "group2"}); 
    group2.orientation = "row"; 
    group2.alignChildren = ["left","center"]; 
    group2.spacing = 10; 
    group2.margins = 0; 

// GROUP3
// ======
var group3 = group2.add("group", undefined, {name: "group3"}); 
    group3.preferredSize.width = 110; 
    group3.orientation = "row"; 
    group3.alignChildren = ["left","center"]; 
    group3.spacing = 10; 
    group3.margins = 0; 

var statictext2 = group3.add("statictext", undefined, undefined, {name: "statictext2"}); 
    statictext2.text = "X :"; 
    statictext2.preferredSize.width = 20; 

var edittext1 = group3.add('edittext {properties: {name: "edittext1"}}'); 
    edittext1.text = "0"; 
    edittext1.preferredSize.width = 60; 
    edittext1.addEventListener ("keyup", function (){
        if(this.text != ""){
            var tmpTxt = "";
            for(var c = 0; c < this.text.length; c++){
                if(parseInt(this.text[c]).toString().toLowerCase() != "nan" || this.text[c] == "."){
                    tmpTxt += this.text[c];
                    }
                }
            this.text = tmpTxt;
            }
        });

// GROUP4
// ======
var group4 = group2.add("group", undefined, {name: "group4"}); 
    group4.orientation = "row"; 
    group4.alignChildren = ["left","center"]; 
    group4.spacing = 10; 
    group4.margins = 0; 

var statictext3 = group4.add("statictext", undefined, undefined, {name: "statictext3"}); 
    statictext3.text = "W :"; 
    statictext3.preferredSize.width = 20; 

var edittext2 = group4.add('edittext {properties: {name: "edittext2"}}'); 
    edittext2.text = "0"; 
    edittext2.preferredSize.width = 60; 
    edittext2.addEventListener ("keyup", function (){
        if(this.text != ""){
            var tmpTxt = "";
            for(var c = 0; c < this.text.length; c++){
                if(parseInt(this.text[c]).toString().toLowerCase() != "nan" || this.text[c] == "."){
                    tmpTxt += this.text[c];
                    }
                }
            this.text = tmpTxt;
            }
        });

// GROUP5
// ======
var group5 = panel1.add("group", undefined, {name: "group5"}); 
    group5.orientation = "row"; 
    group5.alignChildren = ["left","center"]; 
    group5.spacing = 10; 
    group5.margins = 0; 

// GROUP6
// ======
var group6 = group5.add("group", undefined, {name: "group6"}); 
    group6.preferredSize.width = 110; 
    group6.orientation = "row"; 
    group6.alignChildren = ["left","center"]; 
    group6.spacing = 10; 
    group6.margins = 0; 

var statictext4 = group6.add("statictext", undefined, undefined, {name: "statictext4"}); 
    statictext4.text = "Y : "; 
    statictext4.preferredSize.width = 20; 

var edittext3 = group6.add('edittext {properties: {name: "edittext3"}}'); 
    edittext3.text = "0"; 
    edittext3.preferredSize.width = 60; 
    edittext3.addEventListener ("keyup", function (){
        if(this.text != ""){
            var tmpTxt = "";
            for(var c = 0; c < this.text.length; c++){
                if(parseInt(this.text[c]).toString().toLowerCase() != "nan" || this.text[c] == "."){
                    tmpTxt += this.text[c];
                    }
                }
            this.text = tmpTxt;
            }
        });

// GROUP7
// ======
var group7 = group5.add("group", undefined, {name: "group7"}); 
    group7.orientation = "row"; 
    group7.alignChildren = ["left","center"]; 
    group7.spacing = 10; 
    group7.margins = 0; 

var statictext5 = group7.add("statictext", undefined, undefined, {name: "statictext5"}); 
    statictext5.text = "H : "; 

var edittext4 = group7.add('edittext {properties: {name: "edittext4"}}'); 
    edittext4.text = "0"; 
    edittext4.preferredSize.width = 60; 
    edittext4.addEventListener ("keyup", function (){
        if(this.text != ""){
            var tmpTxt = "";
            for(var c = 0; c < this.text.length; c++){
                if(parseInt(this.text[c]).toString().toLowerCase() != "nan" || this.text[c] == "."){
                    tmpTxt += this.text[c];
                    }
                }
            this.text = tmpTxt;
            }
        });

// DIALOG
// ======
var divider1 = dialog.add("panel", undefined, undefined, {name: "divider1"}); 
    divider1.alignment = "fill"; 

// GROUP8
// ======
var group8 = dialog.add("group", undefined, {name: "group8"}); 
    group8.preferredSize.width = 270; 
    group8.orientation = "row"; 
    group8.alignChildren = ["left","center"]; 
    group8.spacing = 10; 
    group8.margins = 0; 

var checkbox1 = group8.add("checkbox", undefined, undefined, {name: "checkbox1"}); 
    checkbox1.text = "Change the object with values : "; 
    checkbox1.onClick = function (){
        group9.enabled = this.value;
        group12.enabled = this.value;
        button1.enabled = this.value;
        if(this.value){
            edittext5.text = edittext1.text;
            edittext6.text = edittext2.text;
            edittext7.text = edittext3.text;
            edittext8.text = edittext4.text;
            }
        else{
            edittext5.text = "";
            edittext6.text = "";
            edittext7.text = "";
            edittext8.text = "";
            }
        }

// PANEL2
// ======
var panel2 = dialog.add("panel", undefined, undefined, {name: "panel2"}); 
    panel2.text = "Change Object"; 
    panel2.preferredSize.width = 270; 
    panel2.preferredSize.height = 100; 
    panel2.orientation = "column"; 
    panel2.alignChildren = ["left","top"]; 
    panel2.spacing = 10; 
    panel2.margins = 10; 

// GROUP9
// ======
var group9 = panel2.add("group", undefined, {name: "group9"}); 
    group9.enabled = false; 
    group9.orientation = "row"; 
    group9.alignChildren = ["left","center"]; 
    group9.spacing = 10; 
    group9.margins = 0; 

// GROUP10
// =======
var group10 = group9.add("group", undefined, {name: "group10"}); 
    group10.preferredSize.width = 110; 
    group10.orientation = "row"; 
    group10.alignChildren = ["left","center"]; 
    group10.spacing = 10; 
    group10.margins = 0; 

var statictext6 = group10.add("statictext", undefined, undefined, {name: "statictext6"}); 
    statictext6.text = "X : "; 

var edittext5 = group10.add('edittext {properties: {name: "edittext5"}}'); 
    edittext5.preferredSize.width = 60; 
    edittext5.addEventListener ("keyup", function (){
        if(this.text != ""){
            var tmpTxt = "";
            for(var c = 0; c < this.text.length; c++){
                if(parseInt(this.text[c]).toString().toLowerCase() != "nan" || this.text[c] == "."){
                    tmpTxt += this.text[c];
                    }
                }
            this.text = tmpTxt;
            }
        });

// GROUP11
// =======
var group11 = group9.add("group", undefined, {name: "group11"}); 
    group11.orientation = "row"; 
    group11.alignChildren = ["left","center"]; 
    group11.spacing = 10; 
    group11.margins = 0; 

var statictext7 = group11.add("statictext", undefined, undefined, {name: "statictext7"}); 
    statictext7.text = "W : "; 

var edittext6 = group11.add('edittext {properties: {name: "edittext6"}}'); 
    edittext6.preferredSize.width = 60; 
    edittext6.addEventListener ("keyup", function (){
        if(this.text != ""){
            var tmpTxt = "";
            for(var c = 0; c < this.text.length; c++){
                if(parseInt(this.text[c]).toString().toLowerCase() != "nan" || this.text[c] == "."){
                    tmpTxt += this.text[c];
                    }
                }
            this.text = tmpTxt;
            }
        });

// GROUP12
// =======
var group12 = panel2.add("group", undefined, {name: "group12"}); 
    group12.enabled = false; 
    group12.orientation = "row"; 
    group12.alignChildren = ["left","center"]; 
    group12.spacing = 10; 
    group12.margins = 0; 

// GROUP13
// =======
var group13 = group12.add("group", undefined, {name: "group13"}); 
    group13.preferredSize.width = 110; 
    group13.orientation = "row"; 
    group13.alignChildren = ["left","center"]; 
    group13.spacing = 10; 
    group13.margins = 0; 

var statictext8 = group13.add("statictext", undefined, undefined, {name: "statictext8"}); 
    statictext8.text = "Y : "; 

var edittext7 = group13.add('edittext {properties: {name: "edittext7"}}'); 
    edittext7.preferredSize.width = 60; 
    edittext7.addEventListener ("keyup", function (){
        if(this.text != ""){
            var tmpTxt = "";
            for(var c = 0; c < this.text.length; c++){
                if(parseInt(this.text[c]).toString().toLowerCase() != "nan" || this.text[c] == "."){
                    tmpTxt += this.text[c];
                    }
                }
            this.text = tmpTxt;
            }
        });

// GROUP14
// =======
var group14 = group12.add("group", undefined, {name: "group14"}); 
    group14.orientation = "row"; 
    group14.alignChildren = ["left","center"]; 
    group14.spacing = 10; 
    group14.margins = 0; 

var statictext9 = group14.add("statictext", undefined, undefined, {name: "statictext9"}); 
    statictext9.text = "H : "; 

var edittext8 = group14.add('edittext {properties: {name: "edittext8"}}'); 
    edittext8.preferredSize.width = 60; 
    edittext8.addEventListener ("keyup", function (){
        if(this.text != ""){
            var tmpTxt = "";
            for(var c = 0; c < this.text.length; c++){
                if(parseInt(this.text[c]).toString().toLowerCase() != "nan" || this.text[c] == "."){
                    tmpTxt += this.text[c];
                    }
                }
            this.text = tmpTxt;
            }
        });

// GROUP15
// =======
var group15 = dialog.add("group", undefined, {name: "group15"}); 
    group15.preferredSize.width = 270; 
    group15.orientation = "row"; 
    group15.alignChildren = ["right","center"]; 
    group15.spacing = 10; 
    group15.margins = 0; 

var button1 = group15.add("button", undefined, undefined, {name: "button1"}); 
    button1.text = "Apply"; 
    button1.enabled = false;

var button2 = group15.add("button", undefined, undefined, {name: "button2"}); 
    button2.text = "Cancel"; 

if(dialog.show() == 1){
    $.bp();
    // Here you can put your execution code ///
    }

 

Regards,

Mike

Likes

Translate

Translate

Report

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
Enthusiast ,
May 01, 2021 May 01, 2021

Copy link to clipboard

Copied

LATEST

Thanks so much indeed, Have a Great day

Best

M.Hasanain

Best
M.Hasanain

Likes

Translate

Translate

Report

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