Widgets not loading in Outlaw

Hello

I’ve been using Outlaw with Corona for some time now and haven’t run into any problems until I tried loading in a widget. I’m wondering if there was some step I missed in setup that helped access the widget library or if it’s something else. Here is a snippet of the code that I’m working on,

I’m following the MasteringCoronaSDK tutorial for tableView and I’m at this step:

local widget = require ( "widget" ) local topOfScreen = display.statusBarHeight --top of usual area local list = nil local RecData = { --huge data library of stuff} local function setup() local bg = display.newRect(0, topOfScreen, display.contentWidth, display.contentHeight - topOfScreen) bg:setFillColor(0, 155, 73) list = widget.newTableView { top = topOfScreen + 10, --where do rows start? height = 304, --length of the list } end local function showRecs() local function onRowRender(event) end --onRowRender local function rowListener(event) end --rowListerner for x = 1, #RecData do list:insertRow{ onRender = onRowRender, listener = rowListener } end end --showRecs setup() showRecs()

The list box isn’t showing up when I press launch like it does in the video. I’m also getting an error stating that “top” (in the tableView setup) is a nil value, leading me to believe that it isn’t loading the tableView widget.

Any help on this would be greatly appreciated. :slight_smile:

EDIT: I’m using Outlaw Lite v 3.0.14 (19)

Should be list=widget.newTablevuew( { } )

I added the parens so it looks like this

list = widget.newTableView ({ top = topOfScreen + 10, --where do rows stop? height = 304, --length of the list })

But I’m still getting the error.

"attempt to preform arithmetic on global ‘top’ (a nil value)
stack traceback:
[C]: ?

Suggest you simplify first in order to find the root cause… Try 

    list = widget.newTableView ({

            top = 0,

            left = 0,

            height = 304,

            width = 320,    })

and see how you go. If this works you can then put your variables back in. Also note I did not see left and width in your table definition and think omitting these might also be aggravating the issue. 

Good luck!

If you’re using the original videos (Biz App Course) you’ll want to follow the instructions on this page to make sure you’re using v1 of the widget library:

http://masteringcoronasdk.com/biz-app-lesson/biz-apps-lesson-0-introduction/

From your code above (looking at line 1), it looks like you’re using v2 that’s baked into the Corona SDK. The Biz App Course was written when v1 was king, so mixing my code with v2 widgets is a shortcut to wailing and gnashing of teeth.

The new videos for v2 TableView should be posted by end of the weekend, and while you could mix v1 + v2 widgets, it might make sense to stick with v1 until the end of the course. 

Make the changes to assure you’re using v1 of the widget library and then see if the problem is still there.

And what Kerem said – simplify the tableView construction to make sure it’s not the topOfScreen variable that’s at fault, etc.

 Jay

Hi guys,

I updated the list definitions so that top was set to zero and not a variable and I’m still getting the “nil” error. On my first run through I had “topOfScreen” labeled as “top” and while it didn’t give me a nil error, it also didn’t show the table on the screen.

I’m not sure which videos I’m using, I found this one through a google search for tableView tutorial (http://masteringcoronasdk.com/biz-app-lesson/biz-apps-lesson-4-scrolling-data-with-tableview-widget). It won’t let me click open the lesson 0 link as I’m not a member. I guess I happened into an area where I wasn’t supposed to be with the first link?

Here’s the stuff I was talking about:

1. Download the Widgets v1 code from here: https://github.com/coronalabs/widget-v1
It’s the file called widget-v1.lua, of course. 

2. Put that file in your project (at the top level, next to main.lua, etc.)

3. Use this line at the top of every file in your project that uses widgets:

local widget = require "widget-v1"

That’s all there is to it, all the existing info will still work and you can use the “old” widgets with the newest build of Corona SDK.

The video you see was left “open” on purpose, but I guess without the secret sauce I just pasted in here it could be confusing to someone coming in from the outside.

 Jay

Awesome, that fixed everything! Thank you so much for your help! :slight_smile:

Should be list=widget.newTablevuew( { } )

I added the parens so it looks like this

list = widget.newTableView ({ top = topOfScreen + 10, --where do rows stop? height = 304, --length of the list })

But I’m still getting the error.

"attempt to preform arithmetic on global ‘top’ (a nil value)
stack traceback:
[C]: ?

Suggest you simplify first in order to find the root cause… Try 

    list = widget.newTableView ({

            top = 0,

            left = 0,

            height = 304,

            width = 320,    })

and see how you go. If this works you can then put your variables back in. Also note I did not see left and width in your table definition and think omitting these might also be aggravating the issue. 

Good luck!

If you’re using the original videos (Biz App Course) you’ll want to follow the instructions on this page to make sure you’re using v1 of the widget library:

http://masteringcoronasdk.com/biz-app-lesson/biz-apps-lesson-0-introduction/

From your code above (looking at line 1), it looks like you’re using v2 that’s baked into the Corona SDK. The Biz App Course was written when v1 was king, so mixing my code with v2 widgets is a shortcut to wailing and gnashing of teeth.

The new videos for v2 TableView should be posted by end of the weekend, and while you could mix v1 + v2 widgets, it might make sense to stick with v1 until the end of the course. 

Make the changes to assure you’re using v1 of the widget library and then see if the problem is still there.

And what Kerem said – simplify the tableView construction to make sure it’s not the topOfScreen variable that’s at fault, etc.

 Jay

Hi guys,

I updated the list definitions so that top was set to zero and not a variable and I’m still getting the “nil” error. On my first run through I had “topOfScreen” labeled as “top” and while it didn’t give me a nil error, it also didn’t show the table on the screen.

I’m not sure which videos I’m using, I found this one through a google search for tableView tutorial (http://masteringcoronasdk.com/biz-app-lesson/biz-apps-lesson-4-scrolling-data-with-tableview-widget). It won’t let me click open the lesson 0 link as I’m not a member. I guess I happened into an area where I wasn’t supposed to be with the first link?

Here’s the stuff I was talking about:

1. Download the Widgets v1 code from here: https://github.com/coronalabs/widget-v1
It’s the file called widget-v1.lua, of course. 

2. Put that file in your project (at the top level, next to main.lua, etc.)

3. Use this line at the top of every file in your project that uses widgets:

local widget = require "widget-v1"

That’s all there is to it, all the existing info will still work and you can use the “old” widgets with the newest build of Corona SDK.

The video you see was left “open” on purpose, but I guess without the secret sauce I just pasted in here it could be confusing to someone coming in from the outside.

 Jay

Awesome, that fixed everything! Thank you so much for your help! :slight_smile: