ComboBox setSelectedId vs setSelectedItemIndex


#1

Just curious:

Why does this work (i.e. auto select the first item)

    addAndMakeVisible (syncModeSelector = new ComboBox());
    syncModeSelector->addItemList ({"Free", "Synced"}, 2);
    syncModeSelector->setSelectedItemIndex (0);

and this not?

    addAndMakeVisible (syncModeSelector = new ComboBox());
    syncModeSelector->addItemList ({"Free", "Synced"}, 2);
    syncModeSelector-> setSelectedId (0);

#2

You are setting firstItemIdOffset to 2, so the id of your first item is 2, not 0. 0 isn’t a valid id.


#3

Oh - I though that 2nd argument was telling it how many items were in my array…