Skip to main content
Adirai Maji
Inspiring
December 27, 2019
Answered

How to make editText uneditable using onChanging or someother method??

  • December 27, 2019
  • 1 reply
  • 759 views

I've a dialog box on my script for a users to read about my script. But I don't want them to change it. I don't want to use staticText either. I've seen lot of script writers have done that to their scripts. I guess they used onChanging method to do that. But I don't know how they did. I'm new to JS and Extended Script. Can someone Explain how to do that with this code???

function helpdialog () {
  var about = new Window('dialog', "About");
  var panelAboutGroup = about.add ('group', undefined, undefined);
  panelAboutGroup.orientation = 'column';
  var aboutEditText = panelAboutGroup.add("statictext", undefined,"I WANT THIS TEXT TO BE STATIC UN EDITABLE" , {multiline: true});
}
This topic has been closed for replies.
Correct answer Adirai Maji

I've done it myself... SORRY I'VE MENTIONED "statictext" INSIDE THE GROUP BY MISTAKE. IT SHOULD BE "edittext"

 

function helpdialog () {
  var about = new Window('dialog', "About");
  var panelAboutGroup = about.add ('group', undefined, undefined);
  panelAboutGroup.orientation = 'column';
  var stableText = "I WANT THIS TEXT TO BE STATIC UN EDITABLE";
  var aboutEditText = panelAboutGroup.add("edittext", undefined, stableText.toString() , {multiline: true});

aboutEditText.onChanging = function(){
      aboutEditText.text= stableText
}

 

1 reply

Adirai Maji
Adirai MajiAuthorCorrect answer
Inspiring
December 27, 2019

I've done it myself... SORRY I'VE MENTIONED "statictext" INSIDE THE GROUP BY MISTAKE. IT SHOULD BE "edittext"

 

function helpdialog () {
  var about = new Window('dialog', "About");
  var panelAboutGroup = about.add ('group', undefined, undefined);
  panelAboutGroup.orientation = 'column';
  var stableText = "I WANT THIS TEXT TO BE STATIC UN EDITABLE";
  var aboutEditText = panelAboutGroup.add("edittext", undefined, stableText.toString() , {multiline: true});

aboutEditText.onChanging = function(){
      aboutEditText.text= stableText
}

 

Tomas Sinkunas
Legend
January 2, 2020

You should be looking at readonly property, such as this:

var et = win.add('statictext', undefined, 'this is\nmultiline text', {
	readonly: true,
	multiline: true
});

 

Adirai Maji
Inspiring
January 3, 2020

Great...!! It works. Thanks for one line answer...!