Hi,
I have a scrollview which I’ve created using the new widget 2.0 scrollview (SV1).
When the user taps a button outside the scrollview SV1, a semi-opaque screen comes up over the whole screen with a menu over it that allows the user to select from several options. This list contains a second scrollview (SV2).
If the user wants to close this menu, they tap anywhere else on the screen except on the menu (so on the semi-opaque screen that’s covering the original scrollview SV1).
The problem is, tapping the semi opaque screen over SV1 causes this scrollview to take focus and so my event handler for tapping the semi opaque screen doesn’t fire.
Prior to widget 2.0 I was using the following code in the tap handler for my semi-opaque overlay:
[lua]if evt.phase == “began” then
if (onList == false) then
display.getCurrentStage():setFocus( self, evt.id )
self.isFocus = true;
end
elseif evt.phase == “ended” then
if (onList == false) then
closeList();
end
end[/lua]
So - how do I pass focus between objects so I can have essentially a large button (my semi opaque screen) over a scrollview and then another scrollview over the top of all that, each working perfectly?
Ideally I’d like to disable the scrollview SV1 completely when the semi-opaque screen comes up but I can’t work our how to do that.
Sorry if that’s confusing!
Thanks,
Ian
Hi Ian,
One option should be to simply “ignore” the scrollView listener when it’s “disabled” (a flag that you set). For example, in the listener function:
[lua]
SV1.disabled = true
local function scrollListener( evt )
if ( SV1.disabled == true ) then return true end
–remainder of listener remains the same
end
[/lua]
Give that a try and let me know if it accomplishes what you need.
Brent
Thanks Brent. I wasn’t aware the scrollview could be set to be disabled like that. I’ll try that out now.
What I did in the meantime was replace my clickable semi-opaque overlay (which was just a graphic with a touch listener) with a Corona widget button and it worked.
Having everything as Corona widgets rather than a combination of those and my own stuff seems to have sorted it (i.e.: Corona’s code works fine until I start messing around with it!!! ;-))
Thanks for the response.
Cheers,
Ian
Hi Ian,
One option should be to simply “ignore” the scrollView listener when it’s “disabled” (a flag that you set). For example, in the listener function:
[lua]
SV1.disabled = true
local function scrollListener( evt )
if ( SV1.disabled == true ) then return true end
–remainder of listener remains the same
end
[/lua]
Give that a try and let me know if it accomplishes what you need.
Brent
Thanks Brent. I wasn’t aware the scrollview could be set to be disabled like that. I’ll try that out now.
What I did in the meantime was replace my clickable semi-opaque overlay (which was just a graphic with a touch listener) with a Corona widget button and it worked.
Having everything as Corona widgets rather than a combination of those and my own stuff seems to have sorted it (i.e.: Corona’s code works fine until I start messing around with it!!! ;-))
Thanks for the response.
Cheers,
Ian