distriqt / airnativeextensions

DEPRECATED: Original repository of the distriqt native extensions and is no longer maintained. Please see our site for the latest ANEs
https://airnativeextensions.com
2 stars 0 forks source link

Get popover dialog selected value #308

Closed crooksy88 closed 8 years ago

crooksy88 commented 9 years ago

Could someone point out how I access the selected value when a popover item is selected?

e.g. Dialog.service.showSelectPopover(1,"Title",["Mr","Mrs","Miss","Ms"],options);

private function popover_changeHandler( event:PopoverEvent ):void { if (event.id == 1) { Dialog.service.dismissPopover( 1 ); trace( "The user changed the selection in the popover to " +event...); } }

So if I select Mrs the trace would read: The user changed the selection in the popover to Mrs

Thanks,

Mark

marchbold commented 9 years ago

If you've specified a single select popover.

private var data:Array = ["Mr", "Mrs", "Miss", "Ms"];

...

Dialog.service.showSelectPopover(1,"Title", data, options );

...

private function popover_changeHandler( event:PopoverEvent ):void
{
    if (event.id == 1)
    {
        // event.selection is an array of selected indexes into the data array
        // with a single select it will only contain one item (but may contain none)

        if (event.selection.length > 0)
            trace( data[ event.selection[0] ] );
    }
}