LiveCode LessonsHow To - LiveCode Mobile Tasks iOS TasksHow do I use the Picker View on an iPhone?

How do I use the Picker View on an iPhone?

This lesson describes how the LiveCode Option Menu is represented and used on the iPhone. Screen captures are provided.

Introduction

In a desktop environment, the Option Menu provides an expanding list from which an item can be selected using a mouse or other pointing device. iPhones are hand held devices that do not support the general use of a mouse. As a result, the iPhone presents a different user interface philosophy when displaying an Option Menu. On the iPhone, the LiveCode Option Menu is represented by a native Picker View.

Creating an Option Menu

Creating an Option Menu

The Option Menu can be created by dragging and dropping the respective control onto a stack or card.

You can then populate the options via the Property Inspector.

In this example, the card contains the Option Menu and a Text Entry Field. The Text Entry Field is provided for reference only and list the values that are stored in the Option Menu.

iPhone Option Menu Support

iPhone Option Menu Support

Once you have loaded your Option Menu application onto an iPhone and you select the control, a Picker View opens. This is a native iPhone control that is base on a spinning wheel analogy.

You can spin through the options on the Picker View in a way that blends into the general iPhone interface design framework.

4 Comments

dirk

How do you use UTF text in a Picker View??

Hanson Schmidt-Cornelius

Hi Dirk,

you can create Unicode entries for the picker wheel by entering Unicode text into the "Menu Items" field of the "Property Inspector". This even allows you to copy and paste a sequence of Unicode text.

Kind Regards,

Hanson

dirk

Thanks Hanson, I was trying to build it from a script - which failed. But yours works of course! :-)

However, can you tell me how to use one of the unicode items that is then picked? It seems to me to return garbage text - eg when I have "Japanese" actually in Japanese in the contents of the option menu, how can I then know when that has been selected? Using "on menuPick pItem" - pItem is non-recognisable.

Any possibility to have a "hidden" column with a corresponding code or some other possibility? eg. returning the line number that was selected?

Or any other suggestions? Thanks!

Hanson Schmidt-Cornelius

Hi Dirk,

if you implement the picker using the "Option Menu" the label of the button is updated with the unicode entry you selected. The "menuPick" event is also passed the option you selected. Indexes to an item are not provided here. A second column with indexes is also not available here.
If you implement the picker programmatically using "mobilePick", then you are returned the item number that corresponds to the item you selected.

In terms of handling unicode, have a look at the dictionary and search for "unicode". You will find a number of entries that allow you to convert between text and Unicode or even put a unicode item somewhere.

Kind Regards,

Hanson

Add your comment

E-Mail me when someone replies to this comment