Tableview layout bug when having defined defaults for anchorX and anchorY

There is a bug when using tableview and having set display.setDefault for anchorX and Y to anything other than 0.5, 0.5

Code below looks like this: ZzQdjlP.png

After commenting out display.setDefault( “anchorX”, 0 ) and display.setDefault( “anchorX”, 0 ) it looks like expected: D1uQY81.png

[lua]
– Copy paste into main.lua
 

There is a bug when using tableview and having set display.setDefault for anchorX and Y to anything other than 0.5, 0.5

Code below looks like this:

After commenting out display.setDefault( “anchorX”, 0 ) and display.setDefault( “anchorX”, 0 ) it looks like expected:

[lua]

– Copy paste into main.lua

display.setStatusBar( display.HiddenStatusBar )

local widget        = require(“widget”)

display.setDefault( “anchorX”, 0 ) – Try commenting out to see difference

display.setDefault( “anchorY”, 0 ) – Try commenting out to see difference

local tableView   = widget.newTableView {

    left            = 0,

    top             = 0,

    topPadding      = 0,

    width           = display.contentWidth, 

    height          = display.contentHeight, 

}

    

tableView.anchorX = 0.5

tableView.anchorY = 0.5

tableView:insertRow{

    rowColor        = {default = {1, 0, 0}}, 

}

[/lua]

[/lua]

I reported it,  case 28095.

Code got mangled when I edited it (took out some non essential lines).

[lua]

– Copy paste into main.lua

display.setStatusBar( display.HiddenStatusBar )

local widget        = require(“widget”)

display.setDefault( “anchorX”, 0 ) – Try commenting out to see difference

display.setDefault( “anchorY”, 0 ) – Try commenting out to see difference

local tableView   = widget.newTableView {

    left            = 0,

    top             = 0,

    topPadding      = 0,

    width           = display.contentWidth, 

    height          = display.contentHeight, 

}

    

tableView.anchorX = 0.5

tableView.anchorY = 0.5

tableView:insertRow{

    rowColor        = {default = {1, 0, 0}}, 

}

[/lua]

I go this too.

I need .setDefault for rest of scene though, I have found that if I add the tableview with default anchors set to 0, it comes up in the wrong place, but then set the anchors to 0.5 for the table afterwards and  it moves to the correct location !

So with anchors set at 0.5, it positions as if the anchors where set to default to 0

Come on Corona, after all the delays in getting any fixes from you on the widgets, please dont introduce new ones !

You should be able to set the defaults to 0, 0, then just before the tableView set it to 0.5, 0.5, then set it back afterwards.

Rob

I tried this, seemed to work but then I got some unexpected results in other scenes. I’m just going to wait until this is fixed in a daily, I presume it is pretty high on the todo list :slight_smile:

This is fixed as of daily build 2085.

Rob

Great, thanks. Seems to work!

Super!!! Thanks much for the quick solution.

Thanks for posting this, I was having the exact same problem.

I noticed when working on the business sample App that I was experiencing a problem where my row’s seem shifted.  It was because I was putting a background on the row using just the call to display.newRect() to handle the positioning:

row.bg = display.newRect(0,0, display.contentWidth, 60)

or something like that.  With Graphics 2.0, that 0, 0 is the center of the rectangle, not the top right corner.  By doing a:

    row.bg = display.newRect(0, 0, display.contentWidth, 60)
    row.bg.anchorX = 0
    row.bg.anchorY = 0

it solved a problem I was having.  The widgets themselves just have their anchor points working.  Things you put in your row still need to honor G2.0 style positioning.

Rob

I reported it,  case 28095.

Code got mangled when I edited it (took out some non essential lines).

[lua]

– Copy paste into main.lua

display.setStatusBar( display.HiddenStatusBar )

local widget        = require(“widget”)

display.setDefault( “anchorX”, 0 ) – Try commenting out to see difference

display.setDefault( “anchorY”, 0 ) – Try commenting out to see difference

local tableView   = widget.newTableView {

    left            = 0,

    top             = 0,

    topPadding      = 0,

    width           = display.contentWidth, 

    height          = display.contentHeight, 

}

    

tableView.anchorX = 0.5

tableView.anchorY = 0.5

tableView:insertRow{

    rowColor        = {default = {1, 0, 0}}, 

}

[/lua]

I go this too.

I need .setDefault for rest of scene though, I have found that if I add the tableview with default anchors set to 0, it comes up in the wrong place, but then set the anchors to 0.5 for the table afterwards and  it moves to the correct location !

So with anchors set at 0.5, it positions as if the anchors where set to default to 0

Come on Corona, after all the delays in getting any fixes from you on the widgets, please dont introduce new ones !

You should be able to set the defaults to 0, 0, then just before the tableView set it to 0.5, 0.5, then set it back afterwards.

Rob

I tried this, seemed to work but then I got some unexpected results in other scenes. I’m just going to wait until this is fixed in a daily, I presume it is pretty high on the todo list :slight_smile:

This is fixed as of daily build 2085.

Rob

Great, thanks. Seems to work!

Super!!! Thanks much for the quick solution.

Thanks for posting this, I was having the exact same problem.