Storyboard API doesn't work with Button Widget

i have my Storyboard demo working fine. But when i tried to add in Button widget, it seems doesn’t work

-- Called when the scene's view does not exist:  
function scene:createScene( event )  
 local group = self.view  
  
 -----------------------------------------------------------------------------  
  
 -- CREATE display objects and add them to 'group' here.  
 -- Example use-case: Restore 'group' from previously saved state.  
  
 -----------------------------------------------------------------------------  
  
 -- SCENE MESSAGE  
 local txtSceneMsg = display.newText("", 0, 0, native.systemFont, 12)  
 txtSceneMsg:setTextColor(255, 255, 255)  
 txtSceneMsg.text = "INDEXSCREEN SCENE"  
 txtSceneMsg.size = 16  
 txtSceneMsg:setReferencePoint(display.TopLeftReferencePoint)  
 txtSceneMsg.x, txtSceneMsg.y = 0, 0  
  
 group:insert(txtSceneMsg)  
  
 -- INITIATE BUTTONS  
 local onButtonEvent = function (event )  
 if event.phase == "release" then  
 print( "You pressed and released a button!" )  
 end  
 end  
   
 local myButton = widget.newButton{  
 id = "btn001",  
 left = 100,  
 top = 200,  
 label = "Widget Button",  
 width = 150, height = 28,  
 cornerRadius = 8,  
 onEvent = onButtonEvent  
 }  
   
 -- Insert button into a group:  
 group:insert(myButton.view)  
  
end  

Terminal Error

The file sandbox for this project is located at the following folder: (/Users/admin/Library/Application Support/Corona Simulator/demo-F467EC21866E9B1BC63ADCE935C64768) Runtime error ...ers/admin/Dropbox/Game Development/demo/sceIndex.lua:58: ERROR: table expected. If this is a function call, you might have used '.' instead of ':' stack traceback: [C]: ? [C]: in function 'insert' ...ers/admin/Dropbox/Game Development/demo/sceIndex.lua:58: in function <...ers development><br> ?: in function 'dispatchEvent'<br> ?: in function 'gotoScene'<br> ...rs/admin/Dropbox/Game Development/demo/sceSplash.lua:55: in function '_listener'<br><br>

it’s complaining line 58, which is below
<br> group:insert(myButton.view)<br>

My understanding from button widget
http://developer.anscamobile.com/reference/index/widgetnewbutton

we should insert “myButton.view” instead of “myButton”, not sure wht goes wrong.
Can someone provide a pointer?

Thanks

- Weilies [import]uid: 10373 topic_id: 20455 reply_id: 320455[/import] </…ers>

Did you require “widget”? Otherwise, I am struggling to find any errors… [import]uid: 62193 topic_id: 20455 reply_id: 80135[/import]

Yup :slight_smile:
the module is required, and i suddenly found out following is working
Case 1

 group:insert(btnPlay)  

but following will NEVER
Case 2

 group:insert(btnPlay.view)  

hopefully someone can clarify me whether i am safe enough to use the case 1

  • Weilies [import]uid: 10373 topic_id: 20455 reply_id: 80145[/import]

weilies, this was due to a change in the API, as of build #721:

Widget API (v0.5b): Added horizontal scrolling and events to scrollView widget. Fixed various tableView bugs and modified rendering algorithm for better performance. Fixed slider bugs. NOTE: Existing widget code will most-likely need to be updated to remain compatible. Made changes to remove “.view” property paradigm (widgets now return a display group). Please see updated widget API documentation. Casenums: 7484, 8849, 9660, 10470, 10783

The documentation is outdated if you are using daily builds. [import]uid: 49447 topic_id: 20455 reply_id: 80165[/import]

Great to hear that producerism!
Thanks for the explanation :slight_smile: [import]uid: 10373 topic_id: 20455 reply_id: 80179[/import]