Refresh Picker

I am trying to learn lua… really like it so far but some I think i am still missing some of the basic things like how to refresh a picker when the data in labels table has changed. How do you update/refresh a picker in realtime ?

Some of the other widgets have a public method called obj:setValue . PickerWheel does not seem to have this yet. 

how do you show changes to the picker then ?

You mean like load values previously stored in a db into a pickerWheel right? Currently there is no way to do this from what I can tell. You can create a feature request and ask Corona Labs to implement this feature. 

pickerWheel is a complicated and delicate widget. It actually combines 3 tableView’s into one view. I think it is possible to create a setValue function for this widget using the tableView:scrollToIndex function. 

ksan,

Thanks for your post, I will try a tableview instead… Have been developing iOS apps but wanted to try this for x/platform… seems very interesting but trying to find the things that are not quite there can be time consuming and very frustrating… oh well…

@sierremanagement, you are most welcome! 

You are spot on with your observation. Corona is 10x faster for the 95% of what you want to do but then that last 5% sometimes eats up all the time you made. Still the xPlatform ability is great! 

The good news is that the source for the widgets have been made opensource so you can peek under the hood to see how they run and find ways to manipulate them. Historically improvements / fixes for widgets did not seem to be a high priority for Corona Labs but this seems to have changed for the better of late. We are getting more frequent updates with some hefty fixes. 

Still there are some gaps in UI elements and consistency (ie text entry etc) but there are some ongoing efforts to plug these through community efforts which is also good news. (search for widget.newEditField on this forum)

Finally, since you have the Obj-C skills you could also consider the Enterprise license option and make native calls when needed to plug the gaps. Just a thought.

Ok. Here’s a quick hack to move pickerWheel columns to a particular position. You can use the tab3 of WidgetDemo sample from CL to try this out. Find the function called showValues and change it to :

local function showValues( event ) -- Loop through all the columns and set the values to 1st value in array for i = 1, #pickerWheel.\_view.\_columns do pickerWheel.\_view.\_columns[i]:scrollToIndex(1) pickerWheel.\_view.\_didTap = true end return true end 

This will essentially move all picker columns to the 1st value in their respective table (ie arrays). The selected state is not set with this code but we might be able to find a way to do that too. Using this sample you can figure out how to programmatically move the picker columns to the respective data row that you wish them to display. Hope this helps.

Oh, this function is called by the button called Values. So run the sample and go to tab 3, click Values.

Do note the code above uses internal variables & references in the widget and CL reserves the right to change these without prior announcement. 

Thanks…

Getting my flashlight and going in… :ph34r:

I’ll alert the authorities if we don’t hear from you in 24 hours! Make sure to pack spare batteries and warm clothes. Many perished along the way.  :slight_smile:

Some of the other widgets have a public method called obj:setValue . PickerWheel does not seem to have this yet. 

how do you show changes to the picker then ?

You mean like load values previously stored in a db into a pickerWheel right? Currently there is no way to do this from what I can tell. You can create a feature request and ask Corona Labs to implement this feature. 

pickerWheel is a complicated and delicate widget. It actually combines 3 tableView’s into one view. I think it is possible to create a setValue function for this widget using the tableView:scrollToIndex function. 

ksan,

Thanks for your post, I will try a tableview instead… Have been developing iOS apps but wanted to try this for x/platform… seems very interesting but trying to find the things that are not quite there can be time consuming and very frustrating… oh well…

@sierremanagement, you are most welcome! 

You are spot on with your observation. Corona is 10x faster for the 95% of what you want to do but then that last 5% sometimes eats up all the time you made. Still the xPlatform ability is great! 

The good news is that the source for the widgets have been made opensource so you can peek under the hood to see how they run and find ways to manipulate them. Historically improvements / fixes for widgets did not seem to be a high priority for Corona Labs but this seems to have changed for the better of late. We are getting more frequent updates with some hefty fixes. 

Still there are some gaps in UI elements and consistency (ie text entry etc) but there are some ongoing efforts to plug these through community efforts which is also good news. (search for widget.newEditField on this forum)

Finally, since you have the Obj-C skills you could also consider the Enterprise license option and make native calls when needed to plug the gaps. Just a thought.

Ok. Here’s a quick hack to move pickerWheel columns to a particular position. You can use the tab3 of WidgetDemo sample from CL to try this out. Find the function called showValues and change it to :

local function showValues( event ) -- Loop through all the columns and set the values to 1st value in array for i = 1, #pickerWheel.\_view.\_columns do pickerWheel.\_view.\_columns[i]:scrollToIndex(1) pickerWheel.\_view.\_didTap = true end return true end 

This will essentially move all picker columns to the 1st value in their respective table (ie arrays). The selected state is not set with this code but we might be able to find a way to do that too. Using this sample you can figure out how to programmatically move the picker columns to the respective data row that you wish them to display. Hope this helps.

Oh, this function is called by the button called Values. So run the sample and go to tab 3, click Values.

Do note the code above uses internal variables & references in the widget and CL reserves the right to change these without prior announcement. 

Thanks…

Getting my flashlight and going in… :ph34r:

I’ll alert the authorities if we don’t hear from you in 24 hours! Make sure to pack spare batteries and warm clothes. Many perished along the way.  :slight_smile:

Bumping this one back up as it’s closest to what I’ve been looking for.

Did anyone ever figure out a way to set the font colour of the automatically selected item? The picker wheel scrolls nicely to the right point (thanks Ksan for your code), but the original, manually selected item retains the highlighted font colour even though it is now no longer the selected item…

Does anyone know if this is possible?

Many thanks,

Ian

Bumping this one back up as it’s closest to what I’ve been looking for.

Did anyone ever figure out a way to set the font colour of the automatically selected item? The picker wheel scrolls nicely to the right point (thanks Ksan for your code), but the original, manually selected item retains the highlighted font colour even though it is now no longer the selected item…

Does anyone know if this is possible?

Many thanks,

Ian