FORUMS: list search recent posts

Retrieving information written by user into "EditText" field to modify a layers text source later

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Sergio Pol
Retrieving information written by user into "EditText" field to modify a layers text source later
on Jan 6, 2015 at 8:03:55 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);


Return to posts index

Dan Ebberts
Re: Retrieving information written by user into "EditText" field to modify a layers text source later
on Jan 6, 2015 at 9:46:26 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



Return to posts index

Sergio Pol
Re: Retrieving information written by user into "EditText" field to modify a layers text source later
on Jan 7, 2015 at 2:05:50 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?


Return to posts index


Sergio Pol
Re: Retrieving information written by user into "EditText" field to modify a layers text source later
on Jan 7, 2015 at 3:21:19 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);
}


Return to posts index


Dan Ebberts
Re: Retrieving information written by user into "EditText" field to modify a layers text source later
on Jan 7, 2015 at 5:17:36 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



Return to posts index

Sergio Pol
Re: Retrieving information written by user into "EditText" field to modify a layers text source later
on Jan 7, 2015 at 6:42:32 pm

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


Return to posts index


Dan Ebberts
Re: Retrieving information written by user into "EditText" field to modify a layers text source later
on Jan 7, 2015 at 6:51:36 pm

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

Dan



Return to posts index

Sergio Pol
Re: Retrieving information written by user into "EditText" field to modify a layers text source later
on Jan 7, 2015 at 6:52:48 pm

Thanks Dan...


Return to posts index

Sergio Pol
Re: Retrieving information written by user into "EditText" field to modify a layers text source later
on Jan 7, 2015 at 9:14:41 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!!


Return to posts index


Dan Ebberts
Re: Retrieving information written by user into "EditText" field to modify a layers text source later
on Jan 7, 2015 at 9:45:36 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



Return to posts index

Sergio Pol
Re: trieving information written by user into "EditText" field to modify a layers text source later
on Jan 8, 2015 at 12:05:43 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.


Return to posts index

Sergio Pol
Re: Retrieving information written by user into "EditText" field to modify a layers text source later
on Jan 9, 2015 at 4:17:16 pm

I finally got it working Dan, thanks for all your help. I still need to have it load ok from the "window" menu but the important functionality works as desired. I find it a nice piece of medium complexity code I wouldn't have come up with without your help so despite the fear of being boring, thank you.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]