Input and Drop-down

Hello,

I am trying to make a program where there is an input field. My goal is to have someone type in a number than have a drop down list of sine, cosine, and tangent. The computer should then give the sine, cosine, or tangent of that number.

I know how to do that except that I need help with a drop-down list and the input field. How do I create these? I know it is possible with html.

Thank you,

Nik

There are several strategies for dealing with the drop down.  Mobile Devices don’t have the same metaphors as web browsers or desktop apps.  What you could do is one of these ideas:

  1. Use a PickerWheel.  This is the iOS style slot wheel where they can dial around to pick the value and it returns the selected value.  This is frequently used by apps were a traditional HTML <select> tag would be used.   But there are other issues with it, like excessive chrome that may be too much.

  2. Use a tableView widget.  Each row in the tableView could be each entry.  This can be a fairly small widget that when touching a button shows up as a panel.  If you’re using storyboard it could be done with an overlay.  If not, you could just create the tableView and have it invisible and when you touch whatever you want to trigger, you can make it visible.

  3. This may be the simplist.  Create a display.newGroup().  Add in buttons for each of your choices, and either using an overlay in storyboard or making the group invisible do what you need to do.

Rob

But when I put 

local widget = require “widget”

widget.newPickerWheel( options )

to get the picker wheel, it doesn’t work. Is there code I should use? Also, about the input fields, how do I get those to appear?

Thank you!

Nik

There should be examples in the documentation near the bottom:  http://docs.coronalabs.com/api/library/widget/newPickerWheel.html

You can also look in the SampleCode/Interface/WidgetDemo to see a pickerWheel in action too.

Rob

There are several strategies for dealing with the drop down.  Mobile Devices don’t have the same metaphors as web browsers or desktop apps.  What you could do is one of these ideas:

  1. Use a PickerWheel.  This is the iOS style slot wheel where they can dial around to pick the value and it returns the selected value.  This is frequently used by apps were a traditional HTML <select> tag would be used.   But there are other issues with it, like excessive chrome that may be too much.

  2. Use a tableView widget.  Each row in the tableView could be each entry.  This can be a fairly small widget that when touching a button shows up as a panel.  If you’re using storyboard it could be done with an overlay.  If not, you could just create the tableView and have it invisible and when you touch whatever you want to trigger, you can make it visible.

  3. This may be the simplist.  Create a display.newGroup().  Add in buttons for each of your choices, and either using an overlay in storyboard or making the group invisible do what you need to do.

Rob

But when I put 

local widget = require “widget”

widget.newPickerWheel( options )

to get the picker wheel, it doesn’t work. Is there code I should use? Also, about the input fields, how do I get those to appear?

Thank you!

Nik

There should be examples in the documentation near the bottom:  http://docs.coronalabs.com/api/library/widget/newPickerWheel.html

You can also look in the SampleCode/Interface/WidgetDemo to see a pickerWheel in action too.

Rob