I use row.reRender() in my apps to change the active row bkg color. How can I do this using the new widgets 2.0?
I use row.reRender() in my apps to change the active row bkg color. How can I do this using the new widgets 2.0?
The documentation for rowColor were not updated properly, but have been fixed and will be correct shortly.
In the meantime, you can set the row’s default and over (pressed/ active ) color now directly from the insertRow method. (On daily build 1047+)
myTableView:insertRow { rowColor = { default = { 255, 255, 255 }, over = { 255, 0, 255 }, -- The row color when it is pressed/held } }
Danny, first thanks for the reply. I had another post in more detail on the old forms and was waiting for over a week for a reply. I know the new rowColor being a table like it is now, and that’s great. However that’s not what I am talking about. I have a message center in my app and when a user selects a message from a tableview on the left the detail/message is loaded on the right. I was using row.reRender to change the row color(NOT the over state color) the whole bkg row color. As far as I know this is NOT possible in widgets 2.0. Here is my code from widgets 1.0 that worked fine:
--ADD THE ROW TOUCH AND SWIPE EVENTS local function onRowTouch( event ) local row = event.target local rowGroup = event.view if event.phase == "press" then if not row.isCategory then --ITERATE THRU THE ROWS AND CHANGE THE COLOR BACK TO ORIGINAL for i=1,table.maxn(list.content.rows) do list.content.rows[i].rowColor = {243,243,243,255} list.content.rows[i].reRender = true end --SET THE ACTIVE ROW BACKGROUND list.content.rows[event.id].rowColor = {255,255,255,255} row.reRender = true --CHANGE THE STATUS OF THE MESSAGE TO READ setMessageAsRead(messageItems[event.index].id) messageItems[event.index].msgRead=true loadMessage(messageItems[event.index].id,messageItems[event.index]) return true end...
I need to give this some thought as to how I want a convenience method of this to work both internally and externally…
However this should work for the time being:
-- Note event.view no longer exists.. -- set the currently touched row's color local row = event.target row.\_border:setFillColor( 255, 0, 0 ) -- Set the other row's color for i = 1, #tableView.\_view.\_rows do local theRow = tableView.\_view.\_rows[i].\_border theRow:setFillColor( 255, 255, 0 ) end
Thank you so much Danny!!! I’ll give that a try for the time being.
Guys, just use the forth parameter equal to zero (it’s alpha) in order to have row transparent
for i = 1, #tableview.\_view.\_rows do local theRow = tableview.\_view.\_rows[i].\_border theRow:setFillColor( 255, 255, 255, 0) end
This was very usefull for me too, thanks.
Where can we find info related to “hidden” properties like _view._row.
Wouldn’be easier to allow in “onRowRender” listener
row.rowColor = someArray
I use row.reRender() in my apps to change the active row bkg color. How can I do this using the new widgets 2.0?
The documentation for rowColor were not updated properly, but have been fixed and will be correct shortly.
In the meantime, you can set the row’s default and over (pressed/ active ) color now directly from the insertRow method. (On daily build 1047+)
myTableView:insertRow { rowColor = { default = { 255, 255, 255 }, over = { 255, 0, 255 }, -- The row color when it is pressed/held } }
Danny, first thanks for the reply. I had another post in more detail on the old forms and was waiting for over a week for a reply. I know the new rowColor being a table like it is now, and that’s great. However that’s not what I am talking about. I have a message center in my app and when a user selects a message from a tableview on the left the detail/message is loaded on the right. I was using row.reRender to change the row color(NOT the over state color) the whole bkg row color. As far as I know this is NOT possible in widgets 2.0. Here is my code from widgets 1.0 that worked fine:
--ADD THE ROW TOUCH AND SWIPE EVENTS local function onRowTouch( event ) local row = event.target local rowGroup = event.view if event.phase == "press" then if not row.isCategory then --ITERATE THRU THE ROWS AND CHANGE THE COLOR BACK TO ORIGINAL for i=1,table.maxn(list.content.rows) do list.content.rows[i].rowColor = {243,243,243,255} list.content.rows[i].reRender = true end --SET THE ACTIVE ROW BACKGROUND list.content.rows[event.id].rowColor = {255,255,255,255} row.reRender = true --CHANGE THE STATUS OF THE MESSAGE TO READ setMessageAsRead(messageItems[event.index].id) messageItems[event.index].msgRead=true loadMessage(messageItems[event.index].id,messageItems[event.index]) return true end...
I need to give this some thought as to how I want a convenience method of this to work both internally and externally…
However this should work for the time being:
-- Note event.view no longer exists.. -- set the currently touched row's color local row = event.target row.\_border:setFillColor( 255, 0, 0 ) -- Set the other row's color for i = 1, #tableView.\_view.\_rows do local theRow = tableView.\_view.\_rows[i].\_border theRow:setFillColor( 255, 255, 0 ) end
Thank you so much Danny!!! I’ll give that a try for the time being.
Guys, just use the forth parameter equal to zero (it’s alpha) in order to have row transparent
for i = 1, #tableview.\_view.\_rows do local theRow = tableview.\_view.\_rows[i].\_border theRow:setFillColor( 255, 255, 255, 0) end
This was very usefull for me too, thanks.
Where can we find info related to “hidden” properties like _view._row.
Wouldn’be easier to allow in “onRowRender” listener
row.rowColor = someArray
I’m trying to use this code to also change the background color of a row when it’s touched (to indicate it’s the active row) and it’s not working properly. I also added a provision for not coloring category rows:
for i = 1, #theList.\_view.\_rows do local listRow = theList.\_view.\_rows[i] if not listRow.isCategory then listRow.\_border:setFillColor(255, 255, 255) end end
What happens is that the tapped row just briefly changes to the over color, or sometime to the custom color I defined, and then back to white. Other times the custom color I chose stays. After about 2-3 clicks on the list, I get errors saying that:
attempt to call method 'setFillColor' (a nil value)
and after that tapping in list rows always brings that error and the row that was tapped doesn’t become “active”. The error occurs on the line of the “if” operator above.
To work correctly, i need to add a method adding that you can invoke in the rows touch listener.
@alll you are not meant to be accessing or modifying the _view property of widgets, hence why it is undocumented
I’m trying to use this code to also change the background color of a row when it’s touched (to indicate it’s the active row) and it’s not working properly. I also added a provision for not coloring category rows:
for i = 1, #theList.\_view.\_rows do local listRow = theList.\_view.\_rows[i] if not listRow.isCategory then listRow.\_border:setFillColor(255, 255, 255) end end
What happens is that the tapped row just briefly changes to the over color, or sometime to the custom color I defined, and then back to white. Other times the custom color I chose stays. After about 2-3 clicks on the list, I get errors saying that:
attempt to call method 'setFillColor' (a nil value)
and after that tapping in list rows always brings that error and the row that was tapped doesn’t become “active”. The error occurs on the line of the “if” operator above.
To work correctly, i need to add a method adding that you can invoke in the rows touch listener.
@alll you are not meant to be accessing or modifying the _view property of widgets, hence why it is undocumented
any update on when we can get something like list.content.rows[i] again?
I would love to know how I can get to a row’s content in widget 2.0. Thanks!
any update on when we can get something like list.content.rows[i] again?