Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Tableview layout bug when having defined defaults for anchorX and anchorY
Started by jonjonsson Nov 18 2013 04:04 AM

10 replies to this topic
[TOPIC CONTROLS]
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

jonjonsson

[GLOBAL: userInfoPane.html]
jonjonsson
  • Corona Geek

  • 1,051 posts
  • Corona SDK

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


-- 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: [URL=http://imgur.com/ZzQdjlP][/URL] After commenting out [b][i]display.setDefault( "anchorX", 0 )[/i][/b] and [i][b]display.setDefault( "anchorX", 0 )[/b][/i] it looks like expected: [URL=http://imgur.com/D1uQY81][/URL]  [lua]-- Copy paste into main.lua display.setStatusBar( display.HiddenStatusBar )local widget        = require("widget") display.setDefault( "anchorX", 0 ) -- Try commenting out to see differencedisplay.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.5tableView.anchorY = 0.5 tableView:insertRow{    rowColor        = {default = {1, 0, 0}}, }[/lua]


Edited by jonjonsson, 18 November 2013 - 11:53 PM.


[TOPIC: post.html]
#2

jonjonsson

[GLOBAL: userInfoPane.html]
jonjonsson
  • Corona Geek

  • 1,051 posts
  • Corona SDK

I reported it,  case 28095.



[TOPIC: post.html]
#3

jonjonsson

[GLOBAL: userInfoPane.html]
jonjonsson
  • Corona Geek

  • 1,051 posts
  • Corona SDK

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

 
-- 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}}, 
}


[TOPIC: post.html]
#4

Richard17

[GLOBAL: userInfoPane.html]
Richard17
  • Enthusiast

  • 89 posts
  • Corona SDK

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 !



[TOPIC: post.html]
#5

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,656 posts
  • Enterprise

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



[TOPIC: post.html]
#6

jonjonsson

[GLOBAL: userInfoPane.html]
jonjonsson
  • Corona Geek

  • 1,051 posts
  • Corona SDK

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 :)



[TOPIC: post.html]
#7

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,656 posts
  • Enterprise

This is fixed as of daily build 2085.

 

Rob



[TOPIC: post.html]
#8

jonjonsson

[GLOBAL: userInfoPane.html]
jonjonsson
  • Corona Geek

  • 1,051 posts
  • Corona SDK

Great, thanks. Seems to work!



[TOPIC: post.html]
#9

ksan

[GLOBAL: userInfoPane.html]
ksan
  • Corona Geek

  • 2,795 posts
  • Corona SDK

Super!!! Thanks much for the quick solution.



[TOPIC: post.html]
#10

disdanes

[GLOBAL: userInfoPane.html]
disdanes
  • Observer

  • 12 posts
  • Corona SDK

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



[TOPIC: post.html]
#11

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,656 posts
  • Enterprise

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




[topic_controls]
[/topic_controls]