newPickerWheel - alignment issues with records after first 5

I am new to Corona and have inherited an existing project. My task was to add a date time object to an existing screen. I found several examples on this and created a stand alone project to get the widget working as I needed. I then add this new lua class( actual 2 lua files) to the main project. Everything seems to work except I have a vertical alignment after the first 5 entries in the all list. The first 5 rows for each column seem to vertical align center. Starting with row 6 each column vertical aligns bottom and then aligns right. If I set the starting index above 5 but below 10 then the first rows, not displayed, also vertical align bottom and align right. Setting the index above 10 results in first 5 rows correct all other off.

I have tried calling coping the prototype code into the main project and calling directly from main. That works. One important difference is that the old project is some conversion from a method before composer. There are the composer.gotoScene calls but call pattern returns a function wrapped object that is not of type scene. I have tried changes to all the properties from the docs, but can not seem to get this working. Any suggestion would be great.

Hi @rbentley and welcome to the forums!

What version of Corona SDK are you using?
 

Can you post your pickerWheel construction code? (Please use code formatting, i.e. the blue <> button in the row with Bold and Italics and copy and paste your code into the popup window).

Thanks

Rob

This is the wrapper to the extend picker wheel. 

----------------------------------------------------------------------------------------- -- -- program: DateTimePicker.lua -- project: -- purpose: -- author : -- date : -- ----------------------------------------------------------------------------------------- local composer = require("composer") local scene = composer.newScene() local widget = require('widget') local dateAndTime = require("framework.datePickerWheel") local loaded local widgets = {} local displayText, datePicker --widget.setTheme("widget\_theme\_ios") -- JRB may not need local device = require('framework.device') local function new(params) -- if DateTimePicker ~=nil then -- remove() logDebugMessage({'DateTimePicker new',params}) --print("JRB here1 " ..params.time) local currYear = tonumber(os.date("%Y")) local currMonth = tonumber(os.date("%m")) local currDay = tonumber(os.date("%d")) local currHr = tonumber(os.date("%H")) local currMin = tonumber(os.date("%M")) local self={ -- JRB need to reduce.. container = display.newGroup(), time = params.time, done = params.done, isForm = params.isForm or false, startY = params.startY or 10, thisObject = params.thisObject } local sceneGroup = self.view if self.time ~= nil and self.time ~= "" then print("What time is it roger? " ..self.time) if tonumber(self.time:sub(1,4)) \> 0 then currYear = self.time:sub(1,4) end if tonumber(self.time:sub(6,7)) \> 0 then currMonth = self.time:sub(6,7) end if tonumber(self.time:sub(9,10)) \> 0 then currDay = self.time:sub(9,10) end if tonumber(self.time:sub(12,13)) \> 0 then currHr = self.time:sub(12,13) end if tonumber(self.time:sub(15,16)) \> 0 then currMin = self.time:sub(15,16) end end local function setDateTime(PassValue,pastTimeDisplay) logDebugMessage({'DateTimePicker done'}) if self.done then self.done(PassValue,pastTimeDisplay) end return true end -- Create the widget. datePicker = widget.newDatePickerWheel(currYear, currMonth, currDay, currHr, currMin, {callBack=setDateTime}) widgets[#widgets+1] = datePicker -- Position it however you like. datePicker.anchorChildren = true datePicker.anchorX = 0.5 datePicker.anchorY = 0 datePicker.x = display.contentCenterX datePicker.y = self.startY self.container:insert(datePicker) local function disableTouch() return true end local function view(fadingTime) if not fadingTime then fadingTime=0 end transition.fadeIn(self.container,{time=fadingTime}) end local function hide(fadingTime) if not fadingTime then fadingTime=0 end transition.fadeOut(self.container,{time=fadingTime}) end local function moveTo(y) self.container.y=y end local function remove() print("I would like to remove my self") local value , text = datePicker.getDT() self.container:removeSelf() self.container=nil return value , text end local function getTime() return self.time,text end local function cancel(event) logDebugMessage({'TimePicker cancel'}) remove() return true end local function onAccept() local values = datePicker:getSelectedDate() print ( "values: " ..values) end local function render() logDebugMessage({'TimePicker render',self.time}) end render() showMem('TimePicker','finished rendering') return { view = view, hide = hide, moveTo = moveTo, remove = remove, setTime = setTime, getTime = getTime } end return {new=new} -- end of TimePicker.lua

I have not cleaned up some of the un-needed code yet as I was still debugging

Here is the extend Wheel.

local widget = require("widget") local lastDateTime = "" local lastFormattedDT = "" local td = {} local function getLimitedDays(thisDate) -- returns a limited range of dates more reasonable for time entry local p = {} local d = {} thisDate = thisDate or os.date("\*t") local startTime = os.time(thisDate) startTime = startTime - (60\*60\*24\*30) -- sec \* min \* hrs \* days local displayDate local actualDate local dispTime = startTime for i = 1,60 do displayDate = os.date("%a", dispTime) .." " ..os.date("%b", dispTime) .." "..os.date("%d", dispTime) -- JRB may have issue with lenght of month and day! actualDate = os.date("%Y", dispTime) .."-" ..os.date("%m", dispTime) .."-" ..os.date("%d", dispTime) --print(displayDate .." " ..actualDate) d[#d+1] = actualDate p[#p+1] = displayDate dispTime = dispTime + (60\*60\*24) -- sec \* min \* hrs end td = d return p, d end local function newWheel(year, month, day, hour, mins) print ("NewWheel: " .." year: " ..year .." month: " ..month .." day: " ..day .." hour: " ..hour .." mins: " ..mins ) local useDate = { year=year, month=month, day=day, hour=hour, min=mins, sec=0 } local printDate, dValue = getLimitedDays(useDate) local idxHr = tonumber(hour) or 1 local idxAMPM = 1 local idxMins = tonumber(mins) or 1 if idxHr \< 1 then idxHr = 12 end if idxHr \> 23 then idxHr = 12 end if idxHr \> 12 then idxHr = idxHr - 12 idxAMPM = 2 end if idxMins \> 59 then idxMins = 60 end if idxMins \< 1 then idxMins = 1 end local columnData = { { -- Day align = "right", width = 140, startIndex = 31, labels = printDate, dateValue = dValue }, { -- Hours align = "center", width = 50, startIndex = idxHr, labels = {"1","2","3","4","5","6","7","8","9","10","11","12"} }, { -- Mins align = "center", width = 50, startIndex = idxMins, labels = {"01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","44","45","46","47","48","49","50","51","52","53","54","55","56","57","58","59","00"} } , { -- Am/Pm align = "center", width = 40, startIndex = idxAMPM, labels = {"AM","PM"} } } return widget.newPickerWheel{columns = columnData, font=native.systemFont} end function widget.newDatePickerWheel(year, month, day, hour, mins, params) year = year or tonumber(os.date("%Y")) month = month or tonumber(os.date("%m")) day = day or tonumber(os.date("%d")) hour = hour or tonumber(os.date("%H")) mins = mins or tonumber(os.date("%M")) local cb={ callBack = params.callBack } local w = display.newGroup() w.wheel = newWheel(year, month, day, hour, mins) w:insert(w.wheel) function w:getValues() return self.wheel:getValues() end function w:getSelectedDate() local values = self:getValues() local formatedDateTime = "" local militaryHour = 0 local tz = os.date('%z') -- CORONA BUG: Sometimes the values can be nil. -- This happens when one of the tables stopped scrolling but hasn't "snapped" to a selected index. -- Prompt the user to fix the bad column. if not values[1] then native.showAlert(\_M.appName, "Please make sure a month is selected.", {"OK"}) elseif not values[2] then native.showAlert(\_M.appName, "Please make sure a day is selected.", {"OK"}) elseif not values[3] then native.showAlert(\_M.appName, "Please make sure a year is selected.", {"OK"}) --else --local valid = validateDate(values[1].index, values[2].value, values[3].value) end -- CORONA BUG: Sometimes the values can be nil. -- This happens when one of the tables stopped scrolling but hasn't "snapped" to a selected index. if not values[1] or not values[2] or not values[3] or not values[4] then return end militaryHour = tonumber(values[2].value) if values[4].value == "PM" then militaryHour = militaryHour + 12 end if militaryHour == 12 then militaryHour = 0 end if militaryHour == 24 then militaryHour = 12 end if militaryHour \< 10 then formatedDateTime = td[values[1].index] .."T0"..militaryHour ..":"..values[3].value ..":00.000" ..string.sub(tz,1,3)..':'..string.sub(tz,4,5) else formatedDateTime = td[values[1].index] .."T"..militaryHour ..":"..values[3].value ..":00.000" ..string.sub(tz,1,3)..':'..string.sub(tz,4,5) end --print ( "Function: formatedDateTime: " ..formatedDateTime .." | " ..td[values[1].index]) return formatedDateTime end function w:monitor() local isoDateTime = w:getSelectedDate() local formatedDateTime = "" if isoDateTime ~= lastDateTime then if isoDateTime ~=nill and isoDateTime ~="" then formatedDateTime = getFormattedDateTime(isoDateTime) --print ( "isoDateTime monitor : " ..isoDateTime) --print ( "formatedDateTime monitor : " ..formatedDateTime) lastDateTime = isoDateTime lastFormattedDT = formatedDateTime cb.callBack(isoDateTime,formatedDateTime) else lastDateTime = "" lastFormattedDT = "" end end end function w:finalize(event) timer.cancel(self.timer) self.timer = nil self.wheel:removeSelf() self.wheel = nil end function w:getDT() return lastDateTime , lastFormattedDT end w:addEventListener("finalize") -- Monitor for changes roughly 30 times per second. w.timer = timer.performWithDelay(33, function() w:monitor() end, -1) return w end

The execution flow is as follows. I have a lua screen. From there I insert a new field into the layout…

fields.startTimeStamp = fieldView.new({parent=sv,label='Start Time',action='datetimepick',text=displayStartDT,value=data.startTimeStamp,finally=validateMandatory,startY=240})

fields comes from

fieldView = require('framework.FieldView')

the FieldView class is really large so here is the starting call…

-- JRB elseif self.action=='datetimepick' then print("JRB in action") if self.dateTimePicker == nil then if self.uiControlCallBack ~= nil then self.uiControlCallBack("disable",self.label) end self.dateTimePicker=dateTimePicker.new({time=self.value,isForm=self.isForm,done=didPickDateTime,startY=self.startY,thisObject=self}) else self.value , self.text = self.dateTimePicker.remove() didPickDateTime(self.value,self.text) self.dateTimePicker = nil if self.uiControlCallBack ~= nil then self.uiControlCallBack("enable",self.label) end end elseif self.action=='url' then

I missed answering this eailer… Version 2016.2949 (2016.9.15)

Are you seeing this in the Simulator or on Device?

If the simulator, what skin do you have selected?

Are you running on WIndows or a Mac?

If you’re running on a device, what device and operating system?

Thanks

Rob

Hi @rbentley,

I would suggest that you upgrade to the current version of Corona (build 2016.2992) and begin utilizing resizable picker wheels. This feature was added very specifically to overcome limitations in the fixed-size wheels you’re inheriting in your project… those must be a dedicated 320x222 pixels which doesn’t always suit an app’s UI. In contrast, resizable picker wheels let you design any size picker, and adjust column widths as needed.

Here’s a tutorial on the topic:

https://coronalabs.com/blog/2016/11/17/widget-updates-resizable-picker-wheels-and-more/

You can still work resizable picker wheels into your existing module. It will just take a little tinkering with the code where that module sets up the picker wheel. The tutorial should help step you through it. :slight_smile:

Hope this helps,

Brent

I downloaded the latest build this morning. Unfortinutly same results. I am going to go back to the original version from the the example and re-intergrate , slowly and see if I can find where I am off.

Thanks for your help

Personally I would stay with 2992. We’ve fixed quite a few things in particular if you plan to submit to Apple or work on macOS 10.12. Even quite a few Windows updates were in the last build. You can still use the fixed sized pickerWheel if that’s what fits your needs.

I would also try building a straight up pickerWheel that bypasses your extensions just to help you narrow down cause.

Rob

Hi @rbentley,

As Rob suggests, I would also recommend you construct a basic picker wheel that doesn’t use the module and see what happens. Just use static labels for now which mimic what your date picker should look like. If the alignment issues don’t appear, then we can at least narrow it down to something happening in the module, not in the widget library itself.

Here’s an example to try:

[lua]

local widget = require( “widget” )

local columnData = {

   { – Day

      align = “right”,

      width = 140,

      startIndex = 4,

      labels = { “Sun Oct 23”,“Mon Oct 24”,“Tue Oct 25”,“Wed Oct 26”,“Thu Oct 27”, “Fri Oct 28”, “Sat Oct 29”, “Sun Oct 30” },

   },  

   { – Hours

      align = “center”,

      width = 50,

      startIndex = 8,

      labels = {“1”,“2”,“3”,“4”,“5”,“6”,“7”,“8”,“9”,“10”,“11”,“12”}

   },

   { – Mins

      align = “center”,

      width = 50,

      startIndex = 30,

      labels = {“01”,“02”,“03”,“04”,“05”,“06”,“07”,“08”,“09”,“10”,“11”,“12”,“13”,“14”,“15”,“16”,“17”,“18”,“19”,“20”,“21”,“22”,“23”,“24”,“25”,“26”,“27”,“28”,“29”,“30”,“31”,“32”,“33”,“34”,“35”,“36”,“37”,“38”,“39”,“40”,“41”,“42”,“43”,“44”,“45”,“46”,“47”,“48”,“49”,“50”,“51”,“52”,“53”,“54”,“55”,“56”,“57”,“58”,“59”,“00”}

   },

   { – Am/Pm

      align = “center”,

      width = 40,

      startIndex = 1,

      labels = {“AM”,“PM”}

   }

}

local wheel = widget.newPickerWheel({

   columns = columnData,

   x = display.contentCenterX,

   y = display.contentCenterY

})

[/lua]

Brent

Thanks for all the help. Sorry it took so long for me to implement the suggestions.

So I took the code from above an implemented into the project. I made a few minor tweaks. Here is the adjusted code.

local widget = require( "widget" ) local function new(params) local columnData = { { -- Day align = "right", width = 140, startIndex = 4, labels = { "Sun Oct 23","Mon Oct 24","Tue Oct 25","Wed Oct 26","Thu Oct 27", "Fri Oct 28", "Sat Oct 29", "Sun Oct 30" }, }, { -- Hours align = "center", width = 50, startIndex = 8, labels = {"1","2","3","4","5","6","7","8","9","10","11","12"} }, { -- Mins align = "center", width = 50, startIndex = 30, labels = {"01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","44","45","46","47","48","49","50","51","52","53","54","55","56","57","58","59","00"} }, { -- Am/Pm align = "center", width = 40, startIndex = 1, labels = {"AM","PM"} } } local wheel = widget.newPickerWheel({ columns = columnData, x = display.contentCenterX, y = display.contentCenterY }) local function remove() print("I would like to remove my self") end end return {new=new} 

Same results. the initial five rows are correct.  Last three records are off. If you scroll to end then back to top then first three records, which were aligned correctly original, are now off. I am going to try and remove the call from the fieldView call back closer to the UI class and see what I get.

So I made the call from the view class and the wheel is still off. There must be some event internal to the wheel which displays the rows not initially shown. Some where in there my code must have stepped on the alignment. The fields are inserted onto the display through use of another class… So if I understand things correctly my UI widget stack is 

Sceen --> from base Corona

    View -> from framework View.lua

        TextField -> from framework FieldView.lua

            PickerWheel -> from test.lua

I have bypassed the textField class. Here is the View.lua

-- View.lua local View = Class( ) local widgetFactory = require( 'widget' ) function View:initialize( ... ) self.view = display.newGroup() self.fields = ... end function View:loadScreen( screen, dataModel ) if( dataModel ) then local eventWidgets = {} local rowCount = 1 local rowKeyX = 50 local rowValX = 190 local scrollView = nil if ( (#dataModel\*rowKeyX) \> display.contentHeight ) then print( 'I need to scroll!' ) scrollView = widgetFactory.newScrollView { width = display.contentWidth, height = display.contentHeight, scrollWidth = display.contentWidth, scrollHeight = 0,--#dataModel \* rowKeyX, horizontalScrollDisabled = true, backgroundColor = { 0, 0, 0 }, listener = handleScroll } end for i, kv in ipairs( dataModel ) do local label, field = unpack( kv ) print( tostring( scrollView ) ) if( scrollView ) then display.newText( scrollView, label, rowKeyX, (50\*rowCount), nil, 17 ) else display.newText( screen, label, rowKeyX, (50\*rowCount), nil, 17 ) end -- native.newTextField( centX, centY, width, height ) --[[local obj = native.newTextField( rowValX, (50\*rowCount), rowValX, 24 ) obj.text = field obj.size = 17 eventWidgets[label] = obj ]]-- rowCount = rowCount + 1 end return eventWidgets end end function handleScroll( event ) local phase = event.phase if ( phase == "began" ) then print( "Scroll view was touched" ) elseif ( phase == "moved" ) then print( "Scroll view was moved" ) elseif ( phase == "ended" ) then print( "Scroll view was released" ) end -- In the event a scroll limit is reached... if ( event.limitReached ) then if ( event.direction == "up" ) then print( "Reached top limit" ) elseif ( event.direction == "down" ) then print( "Reached bottom limit" ) elseif ( event.direction == "left" ) then print( "Reached left limit" ) elseif ( event.direction == "right" ) then print( "Reached right limit" ) end end return true end return View

Hi @rbentley,

You must still have some other module or code base which is overriding the core Corona widget library. Or, you are doing something else that is pinpointing or tweaking the labels.

If I copy your exact code from the post above (where you did not use the “view” class), and I run it in a new/blank Corona project, the picker looks perfect to me. No mis-alignment issues whatsoever.

I’m using the latest public build for testing: 2016.2992.

Best regards,

Brent

Hi @rbentley and welcome to the forums!

What version of Corona SDK are you using?
 

Can you post your pickerWheel construction code? (Please use code formatting, i.e. the blue <> button in the row with Bold and Italics and copy and paste your code into the popup window).

Thanks

Rob

This is the wrapper to the extend picker wheel. 

----------------------------------------------------------------------------------------- -- -- program: DateTimePicker.lua -- project: -- purpose: -- author : -- date : -- ----------------------------------------------------------------------------------------- local composer = require("composer") local scene = composer.newScene() local widget = require('widget') local dateAndTime = require("framework.datePickerWheel") local loaded local widgets = {} local displayText, datePicker --widget.setTheme("widget\_theme\_ios") -- JRB may not need local device = require('framework.device') local function new(params) -- if DateTimePicker ~=nil then -- remove() logDebugMessage({'DateTimePicker new',params}) --print("JRB here1 " ..params.time) local currYear = tonumber(os.date("%Y")) local currMonth = tonumber(os.date("%m")) local currDay = tonumber(os.date("%d")) local currHr = tonumber(os.date("%H")) local currMin = tonumber(os.date("%M")) local self={ -- JRB need to reduce.. container = display.newGroup(), time = params.time, done = params.done, isForm = params.isForm or false, startY = params.startY or 10, thisObject = params.thisObject } local sceneGroup = self.view if self.time ~= nil and self.time ~= "" then print("What time is it roger? " ..self.time) if tonumber(self.time:sub(1,4)) \> 0 then currYear = self.time:sub(1,4) end if tonumber(self.time:sub(6,7)) \> 0 then currMonth = self.time:sub(6,7) end if tonumber(self.time:sub(9,10)) \> 0 then currDay = self.time:sub(9,10) end if tonumber(self.time:sub(12,13)) \> 0 then currHr = self.time:sub(12,13) end if tonumber(self.time:sub(15,16)) \> 0 then currMin = self.time:sub(15,16) end end local function setDateTime(PassValue,pastTimeDisplay) logDebugMessage({'DateTimePicker done'}) if self.done then self.done(PassValue,pastTimeDisplay) end return true end -- Create the widget. datePicker = widget.newDatePickerWheel(currYear, currMonth, currDay, currHr, currMin, {callBack=setDateTime}) widgets[#widgets+1] = datePicker -- Position it however you like. datePicker.anchorChildren = true datePicker.anchorX = 0.5 datePicker.anchorY = 0 datePicker.x = display.contentCenterX datePicker.y = self.startY self.container:insert(datePicker) local function disableTouch() return true end local function view(fadingTime) if not fadingTime then fadingTime=0 end transition.fadeIn(self.container,{time=fadingTime}) end local function hide(fadingTime) if not fadingTime then fadingTime=0 end transition.fadeOut(self.container,{time=fadingTime}) end local function moveTo(y) self.container.y=y end local function remove() print("I would like to remove my self") local value , text = datePicker.getDT() self.container:removeSelf() self.container=nil return value , text end local function getTime() return self.time,text end local function cancel(event) logDebugMessage({'TimePicker cancel'}) remove() return true end local function onAccept() local values = datePicker:getSelectedDate() print ( "values: " ..values) end local function render() logDebugMessage({'TimePicker render',self.time}) end render() showMem('TimePicker','finished rendering') return { view = view, hide = hide, moveTo = moveTo, remove = remove, setTime = setTime, getTime = getTime } end return {new=new} -- end of TimePicker.lua

I have not cleaned up some of the un-needed code yet as I was still debugging

Here is the extend Wheel.

local widget = require("widget") local lastDateTime = "" local lastFormattedDT = "" local td = {} local function getLimitedDays(thisDate) -- returns a limited range of dates more reasonable for time entry local p = {} local d = {} thisDate = thisDate or os.date("\*t") local startTime = os.time(thisDate) startTime = startTime - (60\*60\*24\*30) -- sec \* min \* hrs \* days local displayDate local actualDate local dispTime = startTime for i = 1,60 do displayDate = os.date("%a", dispTime) .." " ..os.date("%b", dispTime) .." "..os.date("%d", dispTime) -- JRB may have issue with lenght of month and day! actualDate = os.date("%Y", dispTime) .."-" ..os.date("%m", dispTime) .."-" ..os.date("%d", dispTime) --print(displayDate .." " ..actualDate) d[#d+1] = actualDate p[#p+1] = displayDate dispTime = dispTime + (60\*60\*24) -- sec \* min \* hrs end td = d return p, d end local function newWheel(year, month, day, hour, mins) print ("NewWheel: " .." year: " ..year .." month: " ..month .." day: " ..day .." hour: " ..hour .." mins: " ..mins ) local useDate = { year=year, month=month, day=day, hour=hour, min=mins, sec=0 } local printDate, dValue = getLimitedDays(useDate) local idxHr = tonumber(hour) or 1 local idxAMPM = 1 local idxMins = tonumber(mins) or 1 if idxHr \< 1 then idxHr = 12 end if idxHr \> 23 then idxHr = 12 end if idxHr \> 12 then idxHr = idxHr - 12 idxAMPM = 2 end if idxMins \> 59 then idxMins = 60 end if idxMins \< 1 then idxMins = 1 end local columnData = { { -- Day align = "right", width = 140, startIndex = 31, labels = printDate, dateValue = dValue }, { -- Hours align = "center", width = 50, startIndex = idxHr, labels = {"1","2","3","4","5","6","7","8","9","10","11","12"} }, { -- Mins align = "center", width = 50, startIndex = idxMins, labels = {"01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","44","45","46","47","48","49","50","51","52","53","54","55","56","57","58","59","00"} } , { -- Am/Pm align = "center", width = 40, startIndex = idxAMPM, labels = {"AM","PM"} } } return widget.newPickerWheel{columns = columnData, font=native.systemFont} end function widget.newDatePickerWheel(year, month, day, hour, mins, params) year = year or tonumber(os.date("%Y")) month = month or tonumber(os.date("%m")) day = day or tonumber(os.date("%d")) hour = hour or tonumber(os.date("%H")) mins = mins or tonumber(os.date("%M")) local cb={ callBack = params.callBack } local w = display.newGroup() w.wheel = newWheel(year, month, day, hour, mins) w:insert(w.wheel) function w:getValues() return self.wheel:getValues() end function w:getSelectedDate() local values = self:getValues() local formatedDateTime = "" local militaryHour = 0 local tz = os.date('%z') -- CORONA BUG: Sometimes the values can be nil. -- This happens when one of the tables stopped scrolling but hasn't "snapped" to a selected index. -- Prompt the user to fix the bad column. if not values[1] then native.showAlert(\_M.appName, "Please make sure a month is selected.", {"OK"}) elseif not values[2] then native.showAlert(\_M.appName, "Please make sure a day is selected.", {"OK"}) elseif not values[3] then native.showAlert(\_M.appName, "Please make sure a year is selected.", {"OK"}) --else --local valid = validateDate(values[1].index, values[2].value, values[3].value) end -- CORONA BUG: Sometimes the values can be nil. -- This happens when one of the tables stopped scrolling but hasn't "snapped" to a selected index. if not values[1] or not values[2] or not values[3] or not values[4] then return end militaryHour = tonumber(values[2].value) if values[4].value == "PM" then militaryHour = militaryHour + 12 end if militaryHour == 12 then militaryHour = 0 end if militaryHour == 24 then militaryHour = 12 end if militaryHour \< 10 then formatedDateTime = td[values[1].index] .."T0"..militaryHour ..":"..values[3].value ..":00.000" ..string.sub(tz,1,3)..':'..string.sub(tz,4,5) else formatedDateTime = td[values[1].index] .."T"..militaryHour ..":"..values[3].value ..":00.000" ..string.sub(tz,1,3)..':'..string.sub(tz,4,5) end --print ( "Function: formatedDateTime: " ..formatedDateTime .." | " ..td[values[1].index]) return formatedDateTime end function w:monitor() local isoDateTime = w:getSelectedDate() local formatedDateTime = "" if isoDateTime ~= lastDateTime then if isoDateTime ~=nill and isoDateTime ~="" then formatedDateTime = getFormattedDateTime(isoDateTime) --print ( "isoDateTime monitor : " ..isoDateTime) --print ( "formatedDateTime monitor : " ..formatedDateTime) lastDateTime = isoDateTime lastFormattedDT = formatedDateTime cb.callBack(isoDateTime,formatedDateTime) else lastDateTime = "" lastFormattedDT = "" end end end function w:finalize(event) timer.cancel(self.timer) self.timer = nil self.wheel:removeSelf() self.wheel = nil end function w:getDT() return lastDateTime , lastFormattedDT end w:addEventListener("finalize") -- Monitor for changes roughly 30 times per second. w.timer = timer.performWithDelay(33, function() w:monitor() end, -1) return w end

The execution flow is as follows. I have a lua screen. From there I insert a new field into the layout…

fields.startTimeStamp = fieldView.new({parent=sv,label='Start Time',action='datetimepick',text=displayStartDT,value=data.startTimeStamp,finally=validateMandatory,startY=240})

fields comes from

fieldView = require('framework.FieldView')

the FieldView class is really large so here is the starting call…

-- JRB elseif self.action=='datetimepick' then print("JRB in action") if self.dateTimePicker == nil then if self.uiControlCallBack ~= nil then self.uiControlCallBack("disable",self.label) end self.dateTimePicker=dateTimePicker.new({time=self.value,isForm=self.isForm,done=didPickDateTime,startY=self.startY,thisObject=self}) else self.value , self.text = self.dateTimePicker.remove() didPickDateTime(self.value,self.text) self.dateTimePicker = nil if self.uiControlCallBack ~= nil then self.uiControlCallBack("enable",self.label) end end elseif self.action=='url' then

I missed answering this eailer… Version 2016.2949 (2016.9.15)

Are you seeing this in the Simulator or on Device?

If the simulator, what skin do you have selected?

Are you running on WIndows or a Mac?

If you’re running on a device, what device and operating system?

Thanks

Rob

Hi @rbentley,

I would suggest that you upgrade to the current version of Corona (build 2016.2992) and begin utilizing resizable picker wheels. This feature was added very specifically to overcome limitations in the fixed-size wheels you’re inheriting in your project… those must be a dedicated 320x222 pixels which doesn’t always suit an app’s UI. In contrast, resizable picker wheels let you design any size picker, and adjust column widths as needed.

Here’s a tutorial on the topic:

https://coronalabs.com/blog/2016/11/17/widget-updates-resizable-picker-wheels-and-more/

You can still work resizable picker wheels into your existing module. It will just take a little tinkering with the code where that module sets up the picker wheel. The tutorial should help step you through it. :slight_smile:

Hope this helps,

Brent

I downloaded the latest build this morning. Unfortinutly same results. I am going to go back to the original version from the the example and re-intergrate , slowly and see if I can find where I am off.

Thanks for your help

Personally I would stay with 2992. We’ve fixed quite a few things in particular if you plan to submit to Apple or work on macOS 10.12. Even quite a few Windows updates were in the last build. You can still use the fixed sized pickerWheel if that’s what fits your needs.

I would also try building a straight up pickerWheel that bypasses your extensions just to help you narrow down cause.

Rob

Hi @rbentley,

As Rob suggests, I would also recommend you construct a basic picker wheel that doesn’t use the module and see what happens. Just use static labels for now which mimic what your date picker should look like. If the alignment issues don’t appear, then we can at least narrow it down to something happening in the module, not in the widget library itself.

Here’s an example to try:

[lua]

local widget = require( “widget” )

local columnData = {

   { – Day

      align = “right”,

      width = 140,

      startIndex = 4,

      labels = { “Sun Oct 23”,“Mon Oct 24”,“Tue Oct 25”,“Wed Oct 26”,“Thu Oct 27”, “Fri Oct 28”, “Sat Oct 29”, “Sun Oct 30” },

   },  

   { – Hours

      align = “center”,

      width = 50,

      startIndex = 8,

      labels = {“1”,“2”,“3”,“4”,“5”,“6”,“7”,“8”,“9”,“10”,“11”,“12”}

   },

   { – Mins

      align = “center”,

      width = 50,

      startIndex = 30,

      labels = {“01”,“02”,“03”,“04”,“05”,“06”,“07”,“08”,“09”,“10”,“11”,“12”,“13”,“14”,“15”,“16”,“17”,“18”,“19”,“20”,“21”,“22”,“23”,“24”,“25”,“26”,“27”,“28”,“29”,“30”,“31”,“32”,“33”,“34”,“35”,“36”,“37”,“38”,“39”,“40”,“41”,“42”,“43”,“44”,“45”,“46”,“47”,“48”,“49”,“50”,“51”,“52”,“53”,“54”,“55”,“56”,“57”,“58”,“59”,“00”}

   },

   { – Am/Pm

      align = “center”,

      width = 40,

      startIndex = 1,

      labels = {“AM”,“PM”}

   }

}

local wheel = widget.newPickerWheel({

   columns = columnData,

   x = display.contentCenterX,

   y = display.contentCenterY

})

[/lua]

Brent