Widgets in CoronaCards

Are widgets supposed to work in CoronaCards for Android?

I tried to include a simple widget:

local testWidget = widget.newSwitch( { left=50, top=cursorY, style=“checkbox” }) 

 

And I got:

 

11-17 16:50:17.396: E/AndroidRuntime(13560): FATAL EXCEPTION: GLThread 30656

11-17 16:50:17.396: E/AndroidRuntime(13560): com.naef.jnlua.LuaRuntimeException: /Users/jenkins/slaveroot/workspace/CoronaCards/OS/android/subrepos/widget/widgetLibrary/widget_switch.lua:64: attempt to index local ‘viewOff’ (a nil value)

11-17 16:50:17.396: E/AndroidRuntime(13560): at com.naef.jnlua.LuaState.lua_pcall(Native Method)

11-17 16:50:17.396: E/AndroidRuntime(13560): at com.naef.jnlua.LuaState.call(Unknown Source)

11-17 16:50:17.396: E/AndroidRuntime(13560): at com.ansca.corona.CoronaLua.dispatchRuntimeEvent(CoronaLua.java:293)

11-17 16:50:17.396: E/AndroidRuntime(13560): at com.ansca.corona.CoronaView$2.executeUsing(CoronaView.java:236)

11-17 16:50:17.396: E/AndroidRuntime(13560): at com.ansca.corona.CoronaRuntimeTaskDispatcher$TaskEvent.Send(CoronaRuntimeTaskDispatcher.java:148)

11-17 16:50:17.396: E/AndroidRuntime(13560): at com.ansca.corona.events.EventManager.sendEvents(EventManager.java:87)

11-17 16:50:17.396: E/AndroidRuntime(13560): at com.ansca.corona.Controller.updateRuntimeState(Controller.java:281)

11-17 16:50:17.396: E/AndroidRuntime(13560): at com.ansca.corona.graphics.opengl.CoronaGLSurfaceView$CoronaRenderer.onDrawFrame(CoronaGLSurfaceView.java:417)

11-17 16:50:17.396: E/AndroidRuntime(13560): at com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1622)

11-17 16:50:17.396: E/AndroidRuntime(13560): at com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1377)

We do not include the widgets library with CoronaCards for Android and iOS.  The reasoning is that you already have access to Apple and Google’s equivalent native UI elements for you to use in Xcode or Eclipse’s UI designers.  Our CoronaCards’ CoronaView is a native UI element that can be used in the same UI designer.  So, it makes sense for our native CoronaView to be more focused on OpenGL/media style rendering.

But that said, our widgets library is open source and you can choose to include it in your project.  You can find it here…

   https://github.com/coronalabs/framework-widget

You can get the newest version of our widgets library by clicking the “Download ZIP” button from the above website.  Once unzipped, copy all of the Lua and PNG files to your Android app project’s “assets” directory.  You also need to copy the “widgetLibrary” subdirectory to your “assets” directory as well (as in that subdirectory needs to exist in your “assets” directory).

Edit:  Corrected the above.  @dchan confirmed that the Lua files do not need to be included… unless you want to replace Corona’s widget library implementation with your own.

On Android the Lua files are already packaged in.  What you need are only the png files.

Thanks for the quick response guys!

We do not include the widgets library with CoronaCards for Android and iOS.  The reasoning is that you already have access to Apple and Google’s equivalent native UI elements for you to use in Xcode or Eclipse’s UI designers.  Our CoronaCards’ CoronaView is a native UI element that can be used in the same UI designer.  So, it makes sense for our native CoronaView to be more focused on OpenGL/media style rendering.

But that said, our widgets library is open source and you can choose to include it in your project.  You can find it here…

   https://github.com/coronalabs/framework-widget

You can get the newest version of our widgets library by clicking the “Download ZIP” button from the above website.  Once unzipped, copy all of the Lua and PNG files to your Android app project’s “assets” directory.  You also need to copy the “widgetLibrary” subdirectory to your “assets” directory as well (as in that subdirectory needs to exist in your “assets” directory).

Edit:  Corrected the above.  @dchan confirmed that the Lua files do not need to be included… unless you want to replace Corona’s widget library implementation with your own.

On Android the Lua files are already packaged in.  What you need are only the png files.

Thanks for the quick response guys!