AI2 Spinner Set to None Selected

The Spinner component in AI2 can prove to be unwieldy at times. The main issue being that should you wish to select the already highlighted item in the spinner list, then the after selecting event will not fire. Until recently, some fairly complicated blocks were required to help overcome this, along with the need to use the "first item" as a heading. Now it seems that the spinner component will accept the blocks setting the selection index to 0 prior to opening the spinner, meaning that none of the items in the list presented are highlighted / selected. It is still necessary to call the spinner from a button, and the spinner still has to be visible, but you can set its height and width to 1 pixel each, and this way it does not interfere with display or layout in your app


Bah...on further testing it seems that on first run of the spinner you cannot select the first item in the list - more work required here...

Best I can come up with is as follows:

  • Add an extra blank item to your spinner elements at the end
  • Select by index this element before calling the spinner
  • Handle the selection of the empty element in the after picking event

It is a little untidy, but perhaps better than the original approach of using the first element as a header....