Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Retrieving information written by user into “EditText” field to modify a layers text source later

  • Retrieving information written by user into “EditText” field to modify a layers text source later

    Posted by Sergio Pol on January 6, 2015 at 8:03 pm

    Hello, I’m rewriting my script following David Torno’s tutorials again and I think I’m on the right path this time. However, something I had managed to figure out with the other method was to be able to retrieve user input from a “prompt();” and then use that info to modify a text layer’s source text. With this method however, the one that allows your script to be run either from the script menu or the window menu, I haven’t been able to do it. What I exactly need is to be able to retrieve that input and collect it to a new variable so I can use it later.

    In addition to that my script doesn’t show anything when run under the window menu. The panel is displayed, it’s dockable and resizable but it shows nothing inside. When it’s run from the script menu all the items are displayed correctly. Any help will be greatly appreciated…

    function entelWow(thisObj){
    function entelWow_buildUI(thisObj){
    var myPanel = (thisObj instanceof Panel) ? thisObj : new Window("palette","textosWow",undefined, {resizeable:true});
    res = "group{orientation:'column',\
    groupOne:Group{orientation:'column',\
    logo: Image{text:'logo', image:'~/Desktop/logoEntel.png'},\
    equipoTE: StaticText{text:'Equipo',alignment:'left'},\
    equipoInput: EditText{text:'',size:[150,25],alignment:'left'},\
    modeloTE: StaticText{text:'Modelo',alignment:'left'},\
    modeloInput: EditText{text:'',size:[150,25],alignment:'left'},\
    costoequipoTE: StaticText{text:'Costo del equipo',alignment:'left'},\
    costEqInput: EditText{text:'',size:[150,25],alignment:'left'},\
    costoequipoTE: StaticText{text:'Costo del plan',alignment:'left'},\
    costPlInput: EditText{text:'',size:[150,25],alignment:'left'},\
    myButton: Button{text:'Aplicar'},\
    },\
    }";
    myPanel.grp = myPanel.add(res);
    var equipo = myPanel.grp.groupOne.equipoInput;
    var modelo = myPanel.grp.groupOne.modeloInput;
    var costoEq = myPanel.grp.groupOne.costEqInput;
    var costoPl = myPanel.grp.groupOne.costPlInput;
    var aplicar = myPanel.grp.groupOne.myButton;
    aplicar.onClick = function(){
    alert(equipo);
    }
    return myPanel;
    }
    var entelPal = entelWow_buildUI(thisObj);
    if((entelPal != null) && (entelPal instanceof Window)){
    entelPal.center();
    entelPal.show();

    }

    }

    entelWow(this);

    Sergio Pol replied 11 years, 4 months ago 2 Members · 11 Replies
  • 11 Replies
  • Dan Ebberts

    January 6, 2015 at 9:46 pm

    I think you need to attach an onChange callback function to your edittext. In that function you would harvest the current user-entered text (this.text , I think) and do what you need to do with it. Or, you could save it into a global variable for use later.

    Dan

  • Sergio Pol

    January 7, 2015 at 2:05 pm

    Thank you Dan I’ll work on that and see how to make it work. Do you have any idea why no content is showing in the panel when loaded from the windows menu?

  • Sergio Pol

    January 7, 2015 at 3:21 pm

    Hello again Dan, right now I’ve managed to collect the info from the user input ok but haven’t been able to modify the source text of the layer. Can you guide me a little? I’ve tried many ways using the language of the method that worked for me before. Back then I made my source text layer a variable as well as the user input and then:

    myText.setValue(input);

    that worked before but right now it returns “undefined” as every other method I tried. Thank you.

    equipo.onChange = function(){equipo = this.text;}

    aplicar.onClick = function(){
    eqText.setValue(equipo);
    }

  • Dan Ebberts

    January 7, 2015 at 5:17 pm

    Something like this should work:

    var mySourceText = yourTextLayer.property(“ADBE Text Properties”).property(“ADBE Text Document”);
    var myTextDoc = mySourceText.value;
    myTextDoc.text = “your text here”;
    mySourceText.setValue(myTextDoc);

    Dan

  • Sergio Pol

    January 7, 2015 at 6:42 pm

    Is it ok to assume that myTextDoc.text is a edittext field made a variable?

  • Dan Ebberts

    January 7, 2015 at 6:51 pm

    Sure, a variable with text stored in it should work fine.

    Dan

  • Sergio Pol

    January 7, 2015 at 6:52 pm

    Thanks Dan…

  • Sergio Pol

    January 7, 2015 at 9:14 pm

    For crying out loud it finally worked!! Thanks a lot Dan. the only difference I see however is the use of the “ADBE…” attributes. So that must be what made it work!!

  • Dan Ebberts

    January 7, 2015 at 9:45 pm

    Actually, any of these formats should work:

    var mySourceText = yourTextLayer.property(“ADBE Text Properties”).property(“ADBE Text Document”);

    var mySourceText = yourTextLayer.property(“Text”).property(“Source Text”);

    var mySourceText = yourTextLayer.text.sourceText;

    Dan

  • Sergio Pol

    January 8, 2015 at 12:05 am

    Hmmm the third option is very simple. I’d use it in future coding no doubt. My prior attempts used the second option, so maybe the thing was creating variables for the source, the text prop and for the user input. Do you remember you helped me setting up a code for a font style change for this same script? Thats the last part of the code that is not working right now. I’ll keep on working around it but perhaps I’ll need help with that again. I wish I knew what I’m doing so I didn’t have to pest this boards this often. I’ve found programming kind of fascinating but it works parts of my brain that were never active I guess. So the poor guy is fighting against stupidity/inactivity.

Page 1 of 2

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy