Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

How to set default option with UI.OptionDialog?

Is there a way to set the selected option when an option dialog is opened? Without it, option dialogs are very confusing for the user. It's a behaviour that can be seen in a lot of native Android apps, at least.

var dialog = Titanium.UI.createOptionDialog({
    options:['Option 1', 'Option 2', 'Option 3'],
    destructive:2,
    cancel:1,
    title:'I am a title'
});

Also, would someone explain what the "destructive" property for OptionDialog does? It's not very clear from the api docs how it differs from the cancel property.

Thanks in advance
Hal

— asked July 15th 2010 by Paul Dowsett
0 Comments

3 Answers

  • Accepted Answer

    It's been raised here for a future release.

    — answered July 29th 2010 by Matt Collinge
    permalink
    2 Comments
    • Err, yes, Matt - I raised it! ;-)

      However, according to the devs, Lighthouse is not intended for feature requests.

      There is currently no way for users to officially request features, or for those requests to be managed in a way that encourages a dialogue with the community.

      — commented July 29th 2010 by Paul Dowsett
    • For anyone needing this, as a workaround, the picker has a very similar popup dialog optionDialog with the advantage of an indicator that shows the currertly selected item.

      — commented November 4th 2010 by Paul Dowsett
  • What do you mean by setting the selected option? If you mean getting the option the user selects you need to add an event listener to capture that.

    The 'destructive' property sets the button as red, commonly found on buttons with titles like 'delete' or 'remove'.

    — answered July 15th 2010 by Sean McEmerson
    permalink
    1 Comment
    • Hi Sean - thanks for the comments.
      By "the selected option" I mean the one that has a green filled circle on its radio button-like control.
      I have no problem with creating event listeners and capturing values.

      Regarding the second point, I am using the android emulator, and I have not seen a red button in an options dialog. As an example of this, the Kitchen Sink/BaseUI/Views/OptionsDialog script has dialog configured with the destructive:2 property/value, with no effect.

      See options_dialog

      — commented July 15th 2010 by Paul Dowsett
  • I want to do the same thing, to set the default already picked OptionDialog item index. According to the documents and KitchenSink, it's not there, but in the next version, they really should add a simple default property so we can set default:currentOption,
    because it makes sense with Radio Buttons to have the current one already ticked. I'd love to see a solution in the next release, and I think other detail oriented developers would agree.

    — answered July 23rd 2010 by Alan Bedian
    permalink
    1 Comment
    • Thanks for your input Alan. Unfortunately, Appcelerator has no official way to raise a Feature Request! :-/

      — commented July 23rd 2010 by Paul Dowsett
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.