Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

serious bug of widget 2.0 ( Please check this... )
Started by bvagdas Mar 03 2013 05:15 PM

5 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

bvagdas

[GLOBAL: userInfoPane.html]
bvagdas
  • Enthusiast

  • 90 posts
  • Corona SDK

Hello guys, Before some days i had seen this bug in my project and i couldnt find out what is this.. To check this out i wrote a simple corona app..
I just created a scrollview widget and within it i inserted a button widget.. When i touch the button it must change the storyboard scene... in THAT point the corona simulator shows me that:
Runtime error
        ?:0: attempt to compare number with nil
stack traceback:
        [C]: ?
        ?: in function '_isWithinBounds'
        ?: in function <?:135>
        ?: in function 'dispatchEvent'
        ?: in function <?:247>
        ?: in function <?:218>
You pressed and released a button!

this is the code..->
----------------------------------------------------------------------------------
--
-- scenetemplate.lua
--
----------------------------------------------------------------------------------

local storyboard = require( "storyboard" )
local widget = require "widget"
local scene = storyboard.newScene()
if (display.pixelWidth > 320) then
display.setStatusBar(display.DefaultStatusBar)
else
display.setStatusBar(display.HiddenStatusBar)
end

----------------------------------------------------------------------------------
-- 
--	NOTE:
--	
--	Code outside of listener functions (below) will only be executed once,
--	unless storyboard.removeScene() is called.
-- 
---------------------------------------------------------------------------------

---------------------------------------------------------------------------------
-- BEGINNING OF YOUR IMPLEMENTATION
---------------------------------------------------------------------------------

-- Called when the scene's view does not exist:
function scene:createScene( event )
	local group = self.view
bg = display.newImageRect("coffeeBg.png",320,480)
bg.x = display.contentWidth/2
bg.y = display.contentHeight/2
 group:insert(bg);


 local scrollView = widget.newScrollView{
 top = 5,
    width = 320,
    height = 430,
    scrollWidth = 320,
    scrollHeight = 430,
	hideBackground=true,
	verticalScrollDisabled = true,
	horizontalScrollDisabled= false,
    maskFile="mask1.png"
	

}
local function handleButton_hotel( event )
    local phase = event.phase 

    if "ended" == phase then
        print( "You pressed and released a button!" );
		storyboard.gotoScene("scenetemplate1");
    end
end
local hotel = widget.newButton
{
    left = 10,
    top = 195,
    width = 136,
    height = 208,
    defaultFile = "hotel.jpg",
    overFile = "hotel_.jpg",
    id = "button_1",
    onEvent = handleButton_hotel
}
scrollView:insert(hotel);

	
group:insert(scrollView);

	-----------------------------------------------------------------------------
		
	--	CREATE display objects and add them to 'group' here.
	--	Example use-case: Restore 'group' from previously saved state.
	
	-----------------------------------------------------------------------------
	
end
-- Called immediately after scene has moved onscreen:
function scene:enterScene( event )
	local group = self.view
	
	-----------------------------------------------------------------------------
		
	--	INSERT code here (e.g. start timers, load audio, start listeners, etc.)
	
	-----------------------------------------------------------------------------
	
end
-- Called when scene is about to move offscreen:
function scene:exitScene( event )
	local group = self.view
	storyboard.removeScene( "scenetemplate" )
	-----------------------------------------------------------------------------
	
	--	INSERT code here (e.g. stop timers, remove listeners, unload sounds, etc.)
	
	-----------------------------------------------------------------------------
	
end
-- Called prior to the removal of scene's "view" (display group)
function scene:destroyScene( event )
	local group = self.view
	
	-----------------------------------------------------------------------------
	
	--	INSERT code here (e.g. remove listeners, widgets, save state, etc.)
	
	-----------------------------------------------------------------------------
	
end
---------------------------------------------------------------------------------
-- END OF YOUR IMPLEMENTATION
---------------------------------------------------------------------------------

-- "createScene" event is dispatched if scene's view does not exist
scene:addEventListener( "createScene", scene )

-- "enterScene" event is dispatched whenever scene transition has finished
scene:addEventListener( "enterScene", scene )

-- "exitScene" event is dispatched before next scene's transition begins
scene:addEventListener( "exitScene", scene )

-- "destroyScene" event is dispatched before view is unloaded, which can be
-- automatically unloaded in low memory situations, or explicitly via a call to
-- storyboard.purgeScene() or storyboard.removeScene().
scene:addEventListener( "destroyScene", scene )

---------------------------------------------------------------------------------

return scene

uid: 185094 topic_id: 36654 reply_id: 336654


[TOPIC: post.html]
#2

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 26,622 posts
  • Enterprise

What Corona build are you using?
uid: 199310 topic_id: 36654 reply_id: 145017


[TOPIC: post.html]
#3

bvagdas

[GLOBAL: userInfoPane.html]
bvagdas
  • Enthusiast

  • 90 posts
  • Corona SDK

firstly this error was appeared from 2013.1038.
I updated yesterday to the last version(1041) hoping this was fixed, but nothing.. it keeps showing up..
I have send a bug report for that, hoping it will be fixed..

From my tests i have figured that this error is showed up only when you insert a widget inside of another.
I am pretty sure that this is a corona bug, because i have the same problem in many projects. Yesterday i wrote the above code, as you can see it is very simple and i think it cant be my fault for generating that error..

On the other hand, i cant understand why no one else has seen the same problem... :(
uid: 185094 topic_id: 36654 reply_id: 145046


[TOPIC: post.html]
#4

bvagdas

[GLOBAL: userInfoPane.html]
bvagdas
  • Enthusiast

  • 90 posts
  • Corona SDK

Hello guys, Before some days i had seen this bug in my project and i couldnt find out what is this.. To check this out i wrote a simple corona app..
I just created a scrollview widget and within it i inserted a button widget.. When i touch the button it must change the storyboard scene... in THAT point the corona simulator shows me that:
Runtime error
        ?:0: attempt to compare number with nil
stack traceback:
        [C]: ?
        ?: in function '_isWithinBounds'
        ?: in function <?:135>
        ?: in function 'dispatchEvent'
        ?: in function <?:247>
        ?: in function <?:218>
You pressed and released a button!

this is the code..->
----------------------------------------------------------------------------------
--
-- scenetemplate.lua
--
----------------------------------------------------------------------------------

local storyboard = require( "storyboard" )
local widget = require "widget"
local scene = storyboard.newScene()
if (display.pixelWidth > 320) then
display.setStatusBar(display.DefaultStatusBar)
else
display.setStatusBar(display.HiddenStatusBar)
end

----------------------------------------------------------------------------------
-- 
--	NOTE:
--	
--	Code outside of listener functions (below) will only be executed once,
--	unless storyboard.removeScene() is called.
-- 
---------------------------------------------------------------------------------

---------------------------------------------------------------------------------
-- BEGINNING OF YOUR IMPLEMENTATION
---------------------------------------------------------------------------------

-- Called when the scene's view does not exist:
function scene:createScene( event )
	local group = self.view
bg = display.newImageRect("coffeeBg.png",320,480)
bg.x = display.contentWidth/2
bg.y = display.contentHeight/2
 group:insert(bg);


 local scrollView = widget.newScrollView{
 top = 5,
    width = 320,
    height = 430,
    scrollWidth = 320,
    scrollHeight = 430,
	hideBackground=true,
	verticalScrollDisabled = true,
	horizontalScrollDisabled= false,
    maskFile="mask1.png"
	

}
local function handleButton_hotel( event )
    local phase = event.phase 

    if "ended" == phase then
        print( "You pressed and released a button!" );
		storyboard.gotoScene("scenetemplate1");
    end
end
local hotel = widget.newButton
{
    left = 10,
    top = 195,
    width = 136,
    height = 208,
    defaultFile = "hotel.jpg",
    overFile = "hotel_.jpg",
    id = "button_1",
    onEvent = handleButton_hotel
}
scrollView:insert(hotel);

	
group:insert(scrollView);

	-----------------------------------------------------------------------------
		
	--	CREATE display objects and add them to 'group' here.
	--	Example use-case: Restore 'group' from previously saved state.
	
	-----------------------------------------------------------------------------
	
end
-- Called immediately after scene has moved onscreen:
function scene:enterScene( event )
	local group = self.view
	
	-----------------------------------------------------------------------------
		
	--	INSERT code here (e.g. start timers, load audio, start listeners, etc.)
	
	-----------------------------------------------------------------------------
	
end
-- Called when scene is about to move offscreen:
function scene:exitScene( event )
	local group = self.view
	storyboard.removeScene( "scenetemplate" )
	-----------------------------------------------------------------------------
	
	--	INSERT code here (e.g. stop timers, remove listeners, unload sounds, etc.)
	
	-----------------------------------------------------------------------------
	
end
-- Called prior to the removal of scene's "view" (display group)
function scene:destroyScene( event )
	local group = self.view
	
	-----------------------------------------------------------------------------
	
	--	INSERT code here (e.g. remove listeners, widgets, save state, etc.)
	
	-----------------------------------------------------------------------------
	
end
---------------------------------------------------------------------------------
-- END OF YOUR IMPLEMENTATION
---------------------------------------------------------------------------------

-- "createScene" event is dispatched if scene's view does not exist
scene:addEventListener( "createScene", scene )

-- "enterScene" event is dispatched whenever scene transition has finished
scene:addEventListener( "enterScene", scene )

-- "exitScene" event is dispatched before next scene's transition begins
scene:addEventListener( "exitScene", scene )

-- "destroyScene" event is dispatched before view is unloaded, which can be
-- automatically unloaded in low memory situations, or explicitly via a call to
-- storyboard.purgeScene() or storyboard.removeScene().
scene:addEventListener( "destroyScene", scene )

---------------------------------------------------------------------------------

return scene

uid: 185094 topic_id: 36654 reply_id: 66654


[TOPIC: post.html]
#5

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 26,622 posts
  • Enterprise

What Corona build are you using?
uid: 199310 topic_id: 36654 reply_id: 145017


[TOPIC: post.html]
#6

bvagdas

[GLOBAL: userInfoPane.html]
bvagdas
  • Enthusiast

  • 90 posts
  • Corona SDK

firstly this error was appeared from 2013.1038.
I updated yesterday to the last version(1041) hoping this was fixed, but nothing.. it keeps showing up..
I have send a bug report for that, hoping it will be fixed..

From my tests i have figured that this error is showed up only when you insert a widget inside of another.
I am pretty sure that this is a corona bug, because i have the same problem in many projects. Yesterday i wrote the above code, as you can see it is very simple and i think it cant be my fault for generating that error..

On the other hand, i cant understand why no one else has seen the same problem... :(
uid: 185094 topic_id: 36654 reply_id: 145046



[topic_controls]
[/topic_controls]