No internet connection
  1. Home
  2. How to

Select from list - Focus on list items in the prompt window (for selection).

By Kitch Membery @Kitch2020-06-21 18:38:44.291Z

Hi @chrscheuer,

With the following example script;

var guitarBrands = ["Fender", "Gibson", "Taylor", "Martin",]

var favoriteGuitarBrand = sf.interaction.selectFromList({
    items: guitarBrands,
    prompt: "Select your favorite guitar brand:",
    defaultItems: ["Fender"],
    onCancel:"Abort",
}).list[0];

log(favoriteGuitarBrand); 

I'd like to have the prompt list window's array list become focused so that I can select items via typing the first letter of the selection I want to choose;

Is this possible?

Thanks!

Solved in post #5, click to view
  • 6 replies
  1. Andrew Scheps @Andrew_Scheps
      2020-06-22 11:18:37.440Z

      I think this is actually a general bug in a lot of the sf.interaction dialogs. They don't come up focused when they first display.

      1. Yea this is because those dialogs are implemented with Apple Script which apparently doesn't focus stuff correctly.

        Instead, use popupSearch which (mostly) takes care of the focusing.

        1. Kitch Membery @Kitch2020-06-22 16:26:58.009Z

          Thanks @chrscheuer, I’ll give that a try!

          1. In reply tochrscheuer:
            Kitch Membery @Kitch2020-06-22 17:25:33.874Z

            Thanks @chrscheuer & @Andrew_Scheps,

            This works great!

            var guitarBrands = ["Fender", "Gibson", "Taylor", "Martin"];
            
            var selectedBrandName = sf.interaction.popupSearch({
                items: guitarBrands.map(name => ({ name: name }))
            }).item.name;
            
            log(selectedBrandName);
            
            Reply1 LikeSolution
        2. J
          In reply toKitch:
          Jonas Orantin @Jonas_Orantin
            2024-02-03 19:41:22.649Z

            Hi @chrscheuer,

            I'm also facing this issue : my sf.interaction.selectFromList dialog doesn't come up focused...
            But I need my selection to be multiple, and I think popupSearch doesn't support it...

            Would you have any suggestion to have a great focused dialog AND the ability to have a multiple selection ?

            I tried to force the focus of the popup dialog with a "bring UI element to front" but it seems not to be a classic UI element...

            Any idea ?

            Thank's

            1. NNicolas Aparicio @Nicolas_Aparicio
                2024-10-28 10:52:02.868Z

                Try this mate: