scrollView:takeFocus() not working in latest build

The takeFocus method is not working for me since updating to the latest daily build. Is anyone else running in to this issue?

Error:
“attempt to call method ‘takeFocus’ (a nil value)”

Code Snippet:

[code]
elseif 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
[/code] [import]uid: 64619 topic_id: 36432 reply_id: 336432[/import]

I think Danny from Corona is on this like a fat kid on cake. There are a few threads going on about this topic. I use the exact same thing in my game in the app store, so I’m in need of a quick fix as well. I found this in the comments section for the widgets 2.0 blog. I don’t know who wrote it, so sorry if I step on any toes.

[lua]
display.getCurrentStage():setFocus( nil )
target.isFocus = false

– set event.target to scrollView and start back at “began” phase
event.target = self._scrollView._view
event.phase = “began”
self._scrollView._view.touch( self._scrollView._view, event )
[/lua] [import]uid: 46082 topic_id: 36432 reply_id: 144636[/import]

Thanks for the info. [import]uid: 64619 topic_id: 36432 reply_id: 144684[/import]

That works now with the new Widgets, thanks. [import]uid: 64619 topic_id: 36432 reply_id: 144804[/import]

I think Danny from Corona is on this like a fat kid on cake. There are a few threads going on about this topic. I use the exact same thing in my game in the app store, so I’m in need of a quick fix as well. I found this in the comments section for the widgets 2.0 blog. I don’t know who wrote it, so sorry if I step on any toes.

[lua]
display.getCurrentStage():setFocus( nil )
target.isFocus = false

– set event.target to scrollView and start back at “began” phase
event.target = self._scrollView._view
event.phase = “began”
self._scrollView._view.touch( self._scrollView._view, event )
[/lua] [import]uid: 46082 topic_id: 36432 reply_id: 144636[/import]

Thanks for the info. [import]uid: 64619 topic_id: 36432 reply_id: 144684[/import]

That works now with the new Widgets, thanks. [import]uid: 64619 topic_id: 36432 reply_id: 144804[/import]

I think Danny from Corona is on this like a fat kid on cake. There are a few threads going on about this topic. I use the exact same thing in my game in the app store, so I’m in need of a quick fix as well. I found this in the comments section for the widgets 2.0 blog. I don’t know who wrote it, so sorry if I step on any toes.

[lua]
display.getCurrentStage():setFocus( nil )
target.isFocus = false

– set event.target to scrollView and start back at “began” phase
event.target = self._scrollView._view
event.phase = “began”
self._scrollView._view.touch( self._scrollView._view, event )
[/lua] [import]uid: 46082 topic_id: 36432 reply_id: 144636[/import]

Thanks for the info. [import]uid: 64619 topic_id: 36432 reply_id: 144684[/import]

That works now with the new Widgets, thanks. [import]uid: 64619 topic_id: 36432 reply_id: 144804[/import]

I think Danny from Corona is on this like a fat kid on cake. There are a few threads going on about this topic. I use the exact same thing in my game in the app store, so I’m in need of a quick fix as well. I found this in the comments section for the widgets 2.0 blog. I don’t know who wrote it, so sorry if I step on any toes.

[lua]
display.getCurrentStage():setFocus( nil )
target.isFocus = false

– set event.target to scrollView and start back at “began” phase
event.target = self._scrollView._view
event.phase = “began”
self._scrollView._view.touch( self._scrollView._view, event )
[/lua] [import]uid: 46082 topic_id: 36432 reply_id: 144636[/import]

Thanks for the info. [import]uid: 64619 topic_id: 36432 reply_id: 144684[/import]

That works now with the new Widgets, thanks. [import]uid: 64619 topic_id: 36432 reply_id: 144804[/import]

 

Hi Sxc,

 

I’ve tried typing in the code, but i get an error with ._scrollView or ._view, does the above mentioned still work for you?  I’m using Build 2013.1053.

Any help would be appreciated!

 

Thanks
B

Got it. Insteading of “._scrollView._view”, “._view” after my scrollview widget worked for me.  Thanks anyways.

B

I’m having the same problem.

 

Error message:

Attempt to call method ‘takeFocus’ (a nil value)

 

I’m guessing this is a bug in the current daily build.

Please could you explain how you solved this?

Are you defining your own takeFocus function?

I tried sXc’s method, instead of using takeFocus which is currently not available for widget 2.0. Upon event.phase == "moved, i set focus to nil, then force my scrollview widget ( “scroller” in my case ) and instruct it to take control and do it’s thing.  Hope that helps.

 

 

    if event.phase == “moved” then

        display.getCurrentStage():setFocus( nil )

        event.target = scroller._view

        event.phase = “began”

        scroller._view.touch( scroller._view, event )

        --scroller:takeFocus( event )

Benny, that solution works like a charm, that you!

 

Hi Sxc,

 

I’ve tried typing in the code, but i get an error with ._scrollView or ._view, does the above mentioned still work for you?  I’m using Build 2013.1053.

Any help would be appreciated!

 

Thanks
B

Got it. Insteading of “._scrollView._view”, “._view” after my scrollview widget worked for me.  Thanks anyways.

B