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

Change property edittext

Community Beginner ,
Jan 07, 2024 Jan 07, 2024

Copy link to clipboard

Copied

Why doesn't this work?

 

function createWindow() {
dialog = new Window("dialog", "My Dialog");

widthLink = dialog.add("edittext", undefined, "Initial Text", { readonly: true });
var editLinkButton = dialog.add("button", undefined, "Edit");

editLinkButton.onClick = function() {
widthLink.readonly = false;


};

dialog.show();
}

createWindow();

TOPICS
Scripting

Views

177

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
Adobe
Guide ,
Jan 07, 2024 Jan 07, 2024

Copy link to clipboard

Copied

"readonly" is a property of an object called "properties".  So the expression to access it would be "widthLink.properties.readonly".  Having said that, it seems to operate exclusively as an argument to add().  It can be overwritten in the next line and it won't do anything.  Off the top of my head, there are two workarounds. 

 

1.  Remove and recreate the edittext, although this produces an unexpected location, even when the bounds are set. 

function createWindow() {
    var dialog = new Window("dialog", "My Dialog");
    var widthLink = dialog.add("edittext", [20, 20, 100, 40], "Initial Text", 
        { readonly: true });
    var editLinkButton = dialog.add("button", undefined, "Edit");
    editLinkButton.onClick = function() {
        dialog.remove(widthLink);
        widthLink = dialog.add("edittext", [20, 20, 100, 40], "Initial Text", 
            { readonly: false });
    };
    dialog.show();
}

createWindow();

 

2.  Recreate the window.

function createWindow(readonly) {
    var dialog = new Window("dialog", "My Dialog");
    widthLink = dialog.add("edittext", undefined, "Initial Text", 
        { readonly: readonly });
    var editLinkButton = dialog.add("button", undefined, "Edit");
    editLinkButton.onClick = function() {
        dialog.close();
        createWindow(false);
    };
    dialog.show();
}

createWindow(true);

 

Votes

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
Community Expert ,
Jan 07, 2024 Jan 07, 2024

Copy link to clipboard

Copied

LATEST

to add to what femkeblanco said, those properties are called "creation properties" which are only set at creation time. Once the dialog is rendered you can read the properties but you can not change them.

Votes

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