Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Listbox .selectedItem, .selection, .??????

  • Listbox .selectedItem, .selection, .??????

    Posted by Scott Mcgee on April 4, 2017 at 3:24 pm

    I have a listbox, I want to be able to take the value from a selected item, hit my apply button and it will put the value into my text layer. I’ve tried .getDisplayedItem, .selectedItem, .selection, .prettyMuchAnythingICanFindOnline.

    The only one that has brough back anything is myList.selection, which brings back “NULL”, everything else either brings back Null is not an object, or it does nothing. Any suggestions?

    //BTN: to apply selected listbox item
    var myBtn = w.add (“button”, undefined, “Apply”);
    var myComp = app.project.activeItem;
    var Text1 = myList.selection;
    myBtn.onClick = function(){
    myComp.layer(“Amount”).property(“ADBE Text Properties”).property(“ADBE Text Document”).setValue(Text1);
    }

    Scott Mcgee replied 9 years, 4 months ago 2 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    April 4, 2017 at 6:16 pm

    In your onClick function, I think this.selection.text should give you the text you want.

    Dan

  • Scott Mcgee

    April 5, 2017 at 8:25 am

    Hey Dan,

    Thanks for the response, but I couldn’t get that too work. I did get another response from the adobe forum with the below. This works, but I forgot the crucially mention that Column 1 is set up from an Array. I managed to fix that aswell, but I can’t seem to get the info I want from column 2.

    //BTN: to apply selected listbox item
    var myBtn = w.add (“button”, undefined, “Apply”);

    myBtn.onClick = function(){

    var myComp = app.project.activeItem; if(!myComp || myComp.typeName !== “Composition”) return;
    var Text1 = myList.selection[0].text;
    var Text2 = “Column 2”
    var textValue = myComp.layer(“”+Text1+””).property(“ADBE Text Properties”).property(“ADBE Text Document”).value;
    textValue.text = Text2;
    myComp.layer(“”+Text1+””).property(“ADBE Text Properties”).property(“ADBE Text Document”).setValue(textValue);
    }

  • Scott Mcgee

    April 5, 2017 at 12:11 pm

    Got the answer (ish), need too fine tune, but it does what I need.

    //BTN: to apply selected listbox item
    var myBtn = w.add (“button”, undefined, “Apply”);

    myBtn.onClick = function(){

    var listSel = myList.selection;
    var myComp = app.project.activeItem; if(!myComp || myComp.typeName !== “Composition”) return;
    var n;

    for (n=0; n

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