Widget 2 Newtableview Question And Comment

First off, thanks for the new widgets…the api and behavior tells me the code behind the scene’s is much cleaner and well designed.  I can feel the solid engineering that went into to this.

Second, a few questions:

#1  I want my “onRowRender” function to be able to read-from (refer to) attributes on it’s parent (ie the TableView object itself).  Making me use upvalues in onRowRender (ORR) prevents me from wrapping your objects with my own generic (and consistent) ORR function.  It also prevents me from changing the row-rendering behavior later in places where the original upvalue data is out-of-scope.  Can you tell me how (or create a hook) to access the parent TV obj from within ORR?  Same request for onRowTouch…want to access the row’s containing TV parent.

#2 Can I change row-height on the fly (for example to display a nested sub-list under a row in the parent table view)?  Other suggestions on how best to achieve an expanded “detail-pane” for a row below it while leaving the rest of the TableView in tact (and still scrollable)?  I noticed in another thread that you might be working on dynamic row-creation and I realize that such a request as above makes your math substantially more complex.

#3  The docs do not clarify inner struct of the object type returned by the “new” widget methods.  I see it’s a Table that has a _view table inside it?  Is this analogous to the “.view” attribute we used to use to access the internal Display Object.   If not, what’s the new way we access the top-most group containing the widget d-objs if we want to do something with them?

Third: Suggestions:

it’s clear that newPickerWheel uses newTableView internally.  Can you give yourself a hidden method to call for this internal use case so I can override the public interface without breaking other widgets?

Hey Corona…your support people said they couldn’t answer my questions (even tho widgets v2 are currently closed source) and sent me to the forums.  I’m here now and still not getting any response to the questions…if my questions are not clear, please let me know…otherwise I’ll start to feel ignored :wink:

I’ll see if I can get someone with better knowledge of the under pinnings of newTableView to respond. 

Before I respond, I want to point out that most of the data in these structures is intended to be private data that you should not have access to.  While reading the data should be safe to the tableView’s operation, we cannot guarantee that these private variables and methods will exist in the future.  Choosing to access data this way creates a situation where we cannot support you.  Writing to any of these private variables will likely have unpredictable results.  There is nothing preventing you from using a printTable() or print_r() type function to dump the table structures and see what’s there.

#2.  I tried to change the height in the onRowTouch function, but there is no rendering going on at that point.  You probably could get the Y position of the row in question, and create your own slide out box to contain your panel, but I’m not aware of any way to do that using our existing widgets.

Hey Rob,

Thanks much for the response.  Let me clarify…my questions about the inner structures are NOT to write to these variables (or even read them for that matter).  Only to understand how it works and what’s possible.  But much more importantly, if you will please re-read my original question #1, I’m wanting to attach MY OWN data to the TableView (the parent of each row), and then be able to access THAT data from within onRowRender() (by reference and NOT VIA upvals).  Hope that clarifies.  And if you can answer THAT question, I’ll be very happy.

There must be someone inside of CoronaLabs who can answer this question:

The onRowRender( event)  [ORR] function receives a call each time a row is to be displayed.

The widget framework gives me a handle to my row_display_object via event.row

How can I traverse the reference chain from the event.row object, to get a reference to the table (or display Obj) containing the ENTIRE tableView widget.  In other words, from INSIDE of ORR, I want to get a reference to the object originally returned from widget.newTableView()

Please…it really can’t be difficult since the row is contained within the parent group…I just need the path.

Or if you can’t answer me that, when will the source be released…seems I read this week???

Thanks,

Dewey

What about creating a module variable for your tableView?

Something like:

local myTV; local onRowRender = function(event) if (event.name == "rowRender") -- use myTV to access any properties end end myTV = widget.newTableView(......, onRowRender=onRowRender);  

I need a reference, not upvalues.   My ORR function, my data rows, and my TV object are created in entirely different places and thus I can’t (and don’t want to) do this with upvalues.   Think clean OOP…

Thanks for the suggestion though.

Someone at Corona please show me how to get a reference to the final parent of the row

Dewey

To get at the TV object…what about using event.target in your ORR?

Yay Ingemar!!!—good guess, or did you find it somewhere!!  

It works in ORR, but does NOT work in onRowTouch…which is weird and inconsistent!!

Corona…please add some detailed documentation for the event records sent to these various widget functions

Great!

I use the Lua Glider IDE for my Corona development. With it I set a breakpoint inside the ORR and inspected the variables for ‘event’, and saw the ‘target’ there.

I did the same for ORT and there’s a ‘target’ there too, but for some reason it points to the same object as ‘row’.

Hi ingemar, dgaedcke,

Although you are correct about the inconsistency between ORR and ORT, you can always go like this inside ORT:

        print(event.target.parent.whateverVariable)

To access the tableview’s global properties.

Hope this helps,

Alex.

Thanks Alex—really appreciate the answer.   Will you guys be adding documentation for the event records being passed??  Also, I thought I heard v2 was also going open-source.  When will that happen?

Thx

Dewey

Already happened :slight_smile:

https://github.com/coronalabs

Hey Corona…your support people said they couldn’t answer my questions (even tho widgets v2 are currently closed source) and sent me to the forums.  I’m here now and still not getting any response to the questions…if my questions are not clear, please let me know…otherwise I’ll start to feel ignored :wink:

I’ll see if I can get someone with better knowledge of the under pinnings of newTableView to respond. 

Alex,

“event.target.parent._data” is not working for me inside of onRowTouch (ORT)

Here is what I’m doing:

local tv = widget.newTableView(tableParams)

tv._data = data – keep ref to the data passed

inside of ORT, I try:

local rowData = event.target.parent._data[event.row.index]

and I get:

       attempt to index field ‘_data’ (a nil value)

I just downloaded the newest daily build so I know it’s not a version problem…about to dig through the source code now

ok, here is the problem:

from line 394 in widget_tableview.lua, you have:

                local newEvent =

                {

                    phase = “release”,

                    target = event.target,

                    row = self._targetRow,

                }

event.target != tableview

and the row (self._targetRow) doesn’t have any attribute pointing to it’s parent either

I can fix my version but then I void the warrantee ;-) 

feedback requested!!

Thx,
D

PS  please use a function to create the event record so it’s consistent throughout the module and does not need to be edited in 6 different places…thanks, you guys rock!

Before I respond, I want to point out that most of the data in these structures is intended to be private data that you should not have access to.  While reading the data should be safe to the tableView’s operation, we cannot guarantee that these private variables and methods will exist in the future.  Choosing to access data this way creates a situation where we cannot support you.  Writing to any of these private variables will likely have unpredictable results.  There is nothing preventing you from using a printTable() or print_r() type function to dump the table structures and see what’s there.

#2.  I tried to change the height in the onRowTouch function, but there is no rendering going on at that point.  You probably could get the Y position of the row in question, and create your own slide out box to contain your panel, but I’m not aware of any way to do that using our existing widgets.

Hey Rob,

Thanks much for the response.  Let me clarify…my questions about the inner structures are NOT to write to these variables (or even read them for that matter).  Only to understand how it works and what’s possible.  But much more importantly, if you will please re-read my original question #1, I’m wanting to attach MY OWN data to the TableView (the parent of each row), and then be able to access THAT data from within onRowRender() (by reference and NOT VIA upvals).  Hope that clarifies.  And if you can answer THAT question, I’ll be very happy.

There must be someone inside of CoronaLabs who can answer this question:

The onRowRender( event)  [ORR] function receives a call each time a row is to be displayed.

The widget framework gives me a handle to my row_display_object via event.row

How can I traverse the reference chain from the event.row object, to get a reference to the table (or display Obj) containing the ENTIRE tableView widget.  In other words, from INSIDE of ORR, I want to get a reference to the object originally returned from widget.newTableView()

Please…it really can’t be difficult since the row is contained within the parent group…I just need the path.

Or if you can’t answer me that, when will the source be released…seems I read this week???

Thanks,

Dewey