scrollview widget blocks touch events on other objects

Hello ,

First i have to say that i am a newbie with corona sdk…
I have a problem with the scrollview object… When i scroll the content , touches on other objects are blocked… i can use these objects again only when the content is again on its starter position.

Is this a bug of corona sdk? or its my fault??
Please someone help me…

[code]
scrollBox = widget.newScrollView{
top = 220,
width = 320, height =250,
scrollWidth = 320, scrollHeight =400,
friction = 0.1,
bgColor = {255,255,255,0} ,
maxVelocity=4,
maskFile = “mask-250 - Copy.png”
}
[import]uid: 185094 topic_id: 32267 reply_id: 332267[/import]

Hello bvagdas

We had the same issue in our project, and the solution to it is to use buttons from widget library.

Krystian [import]uid: 109453 topic_id: 32267 reply_id: 130149[/import]

Hello bvagdas

We had the same issue in our project, and the solution to it is to use buttons from widget library.

Krystian [import]uid: 109453 topic_id: 32267 reply_id: 130149[/import]

Hey Bvagdas and Krystian,

You do not really need the buttons widget to get touch-input inside a scrollview. I made my images clickable by using the following code:

[lua]local function onTileTouch( event )
if event.phase == “moved” then – Check if you moved your finger while touching

local dx = math.abs( event.x - event.xStart ) – Get the x-transition of the touch-input
local dy = math.abs( event.y - event.yStart ) – Get the y-transition of the touch-input

if dx > 5 or dy > 5 then
scrollView:takeFocus( event ) – If the x- or y-transition is more than 5 put the focus to your scrollview
end

elseif event.phase == “ended” then

– Here the code you want to execute when the item is touched.

end

return true
end

image:addEventListener( “touch”, onTileTouch )[/lua]

If the touches are still blocked we probably need more code to help you although I hope this works for you. [import]uid: 189912 topic_id: 32267 reply_id: 130267[/import]

Any other objects than widgets won’t get touch listener triggered when the invisible part of the scrollview is over or under the object.

Let’s say you have a scrollview with a mask of 200x200 in the middle of your screen.
Directly below this you have an object with touch listener. The content of the scrollview is 200x800.
Scrollview is in a group A.
Object with touch listener is in group B.
Global group C contains group A and group B over group A.

The only moment, my objects’ touch listener will be triggered is when I scroll the content of the scrollview max to the top, so that it’s nowhere near the object. [import]uid: 109453 topic_id: 32267 reply_id: 130272[/import]

Hey Bvagdas and Krystian,

You do not really need the buttons widget to get touch-input inside a scrollview. I made my images clickable by using the following code:

[lua]local function onTileTouch( event )
if event.phase == “moved” then – Check if you moved your finger while touching

local dx = math.abs( event.x - event.xStart ) – Get the x-transition of the touch-input
local dy = math.abs( event.y - event.yStart ) – Get the y-transition of the touch-input

if dx > 5 or dy > 5 then
scrollView:takeFocus( event ) – If the x- or y-transition is more than 5 put the focus to your scrollview
end

elseif event.phase == “ended” then

– Here the code you want to execute when the item is touched.

end

return true
end

image:addEventListener( “touch”, onTileTouch )[/lua]

If the touches are still blocked we probably need more code to help you although I hope this works for you. [import]uid: 189912 topic_id: 32267 reply_id: 130267[/import]

Ah now I get the problem, I misunderstood it. Thought he meant that he couldn’t touch objects inside the scrollview but he means he couldn’t touch objects outside the scrollview. My bad. :wink: [import]uid: 189912 topic_id: 32267 reply_id: 130275[/import]

Any other objects than widgets won’t get touch listener triggered when the invisible part of the scrollview is over or under the object.

Let’s say you have a scrollview with a mask of 200x200 in the middle of your screen.
Directly below this you have an object with touch listener. The content of the scrollview is 200x800.
Scrollview is in a group A.
Object with touch listener is in group B.
Global group C contains group A and group B over group A.

The only moment, my objects’ touch listener will be triggered is when I scroll the content of the scrollview max to the top, so that it’s nowhere near the object. [import]uid: 109453 topic_id: 32267 reply_id: 130272[/import]

Ah now I get the problem, I misunderstood it. Thought he meant that he couldn’t touch objects inside the scrollview but he means he couldn’t touch objects outside the scrollview. My bad. :wink: [import]uid: 189912 topic_id: 32267 reply_id: 130275[/import]

@bvagdas

I just learned that setting:

scrollView.isHitTestMasked = true  

will disable hits on the masked area.
According to documentation it should be set to true by default, but we all know how good corona docs are… :wink: [import]uid: 109453 topic_id: 32267 reply_id: 130435[/import]

@bvagdas

I just learned that setting:

scrollView.isHitTestMasked = true  

will disable hits on the masked area.
According to documentation it should be set to true by default, but we all know how good corona docs are… :wink: [import]uid: 109453 topic_id: 32267 reply_id: 130435[/import]

wrong post :> [import]uid: 109453 topic_id: 32267 reply_id: 130530[/import]

wrong post :> [import]uid: 109453 topic_id: 32267 reply_id: 130530[/import]

dear sparky and krystian

i mean of course touching objects outside the scrolview… i am not using button widget , i am using a single imageRect with a touch event on that.

for some reason the problem is that when i scroll the content of scrollview this overlaps the imageRect. [import]uid: 185094 topic_id: 32267 reply_id: 130918[/import]

dear sparky and krystian

i mean of course touching objects outside the scrolview… i am not using button widget , i am using a single imageRect with a touch event on that.

for some reason the problem is that when i scroll the content of scrollview this overlaps the imageRect. [import]uid: 185094 topic_id: 32267 reply_id: 130918[/import]

bvagdas:

just like I’ve said, set:

isHitTestMasked = true  

property on the scrollview and problem will go away. [import]uid: 109453 topic_id: 32267 reply_id: 131201[/import]

Thanks krystian! You solve my problem!! Can i ask you something else?? i am using storyboard and i am wondering if is there a way to change scenes by pressing the android hardware back button…
I Tried this , but it’s not working :

[code]
local function onKeyEvent( event )
local phase = event.phase
local keyName = event.keyName

if (keyName == “back”)
storyboard.gotoScene( “scene1” , “slideLeft”, 400 );
end

return true
end

– Add the key callback
Runtime:addEventListener( “key”, onKeyEvent ); [import]uid: 185094 topic_id: 32267 reply_id: 131224[/import]

bvagdas:

just like I’ve said, set:

isHitTestMasked = true  

property on the scrollview and problem will go away. [import]uid: 109453 topic_id: 32267 reply_id: 131201[/import]

Thanks krystian! You solve my problem!! Can i ask you something else?? i am using storyboard and i am wondering if is there a way to change scenes by pressing the android hardware back button…
I Tried this , but it’s not working :

[code]
local function onKeyEvent( event )
local phase = event.phase
local keyName = event.keyName

if (keyName == “back”)
storyboard.gotoScene( “scene1” , “slideLeft”, 400 );
end

return true
end

– Add the key callback
Runtime:addEventListener( “key”, onKeyEvent ); [import]uid: 185094 topic_id: 32267 reply_id: 131224[/import]

!bvagdas

sorry, I’m not using storyboard and I create universal games, so I don’t handle key events.

Better create a separate thread. [import]uid: 109453 topic_id: 32267 reply_id: 131467[/import]