handler for control object unable to use UIevent object

New Here ,
Aug 31, 2022 Aug 31, 2022

Copy link to clipboard


I'm trying to put the input from an edittext object into a variable, which I then place onto the document in the form of a text layer. For some reason, the UIevent object in the function I'm passing into the event listener won't do anything. The function works just fine, I tested it by having it create a layer every time it's called.

Code here:

var textBoxRefContents = "placeholder";
var textBoxRef = dlg.add('edittext', {x: undefined, y: undefined, width: 150, height: undefined}, undefined, undefined);
textBoxRef.alignment = 'left';
textBoxRef.title = 'sample';
textBoxRef.addEventListener('changing', function( e ){
    textBoxRefContents = e.currentTarget.text;
textBoxRef = null;

var closeBtnRef = dlg.add('button', undefined, 'Ok', {name: 'okbtn'});
//figure out how to get it to stay at bottom right
closeBtnRef.visible = true;
closeBtnRef.location = [dlg.size.width, dlg.size.height];
closeBtnRef.addEventListener('click', create(textBoxRefContents));
closeBtnRef = null;

function create(textBoxRefContents) {
        docRef = app.documents.add(1920, 1080, 100, 'doc');
        newLayerRef = docRef.artLayers.add();
        //newLayerRef.name = 'this is what you had input';
        newLayerRef.kind = LayerKind.TEXT;
        newLayerRef.position = [
                new UnitValue(100, 'px'),
                new UnitValue(100, 'px')
        newLayerRef.textItem.size = 64;
        newLayerRef.textItem.color.rgb.hexValue = 'BD2D2D';
        newLayerRef.textItem.contents = textBoxRefContents;
Actions and scripting , Windows







Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
no replies

Have something to add?

Join the conversation