Widget 2.0 newScrollView - takeFocus() method?

Could you give a small code sample on how to get this temporary workaround done correctly?

In my implementation I can only scroll if I touch the screen right in between the interactive objects (which is quite difficult).

I too would appreciate an example of how to get the work-around code working it that’s possible.

The problem I’m finding is whilst:

(a) I do a “return false” to let the button listener let go of the event, and then the scroller takes it up ok - so it does start scrolling (I have to move it manually)

(b) the button listener still picks up the “ended” event when the user lifts their finger off after scrolling, which then means the button gets pressed at the end of the scrolling event when it shouldn’t

local function levelButtonListener(event)     if event.phase == "moved" then         local dx = math.abs( event.x - event.xStart )         local dy = math.abs( event.y - event.yStart )         if dx \> 5 or dy \> 5 then             -- Long Term Appoach (But Isssue Until Error resolved)             --             scroller:takeFocus( event )        -- ERROR:  KNOWN ERROR TO BE FIXED BY CORONA: http://forums.coronalabs.com/topic/30284-widget-20-newscrollview-                         -- Short Term Work Around             return false         else             -- print("Small movement only")         end     else event.phase == "ended" then                            launchGameScene(event.target.level)     end     return true end  

any update?  

Yes, see this: http://forums.coronalabs.com/topic/33579-info-scrollview-take-focus-is-coming-back/

Thanks Danny - does this mean it will be automatically included as part of widget.newButton()?

Or will we have to include the code in the “moved” phase of the event handler for the button? If so, can we still use it with the 9 slice widget buttons or am I going to have to make my own image buttons?

Thanks,

Ian

You will call takeFocus() in the “moved” phase for widget buttons also. This is subject to change as we can automatically do this for widget buttons but there is always the point that everyone has a different opinion on when the button should pass focus back to the scrollView so for now you manage it from your code.

Thanks

Thanks Danny. Any idea when this will be implemented?

TakeFocus is already implemented (locally) if your question is when will it automatically work with buttons, I guess that just depends on how many people want it.

Thanks

Ok great so with the latest daily build I can use TakeFocus in the same way I used to (it was taken out for a while)…?

Thanks.

No sorry, by locally I meant on my computer. It will be available very soon :slight_smile:

Ah okay! Great - look forward to it. Thanks.

Hi Danny

Can you do a post on this thread when it is released?

Is there a work around for the moment re how to push-hold-drag backwards and forwards items within a scroll view? Or was takeFocus the only way to do this? Assuming we have buttons in the scroll view that work separately if you click on them.

Can we get an update on when this will make it into the daily builds?

Could you give a small code sample on how to get this temporary workaround done correctly?

In my implementation I can only scroll if I touch the screen right in between the interactive objects (which is quite difficult).

I too would appreciate an example of how to get the work-around code working it that’s possible.

The problem I’m finding is whilst:

(a) I do a “return false” to let the button listener let go of the event, and then the scroller takes it up ok - so it does start scrolling (I have to move it manually)

(b) the button listener still picks up the “ended” event when the user lifts their finger off after scrolling, which then means the button gets pressed at the end of the scrolling event when it shouldn’t

local function levelButtonListener(event)     if event.phase == "moved" then         local dx = math.abs( event.x - event.xStart )         local dy = math.abs( event.y - event.yStart )         if dx \> 5 or dy \> 5 then             -- Long Term Appoach (But Isssue Until Error resolved)             --             scroller:takeFocus( event )        -- ERROR:  KNOWN ERROR TO BE FIXED BY CORONA: http://forums.coronalabs.com/topic/30284-widget-20-newscrollview-                         -- Short Term Work Around             return false         else             -- print("Small movement only")         end     else event.phase == "ended" then                            launchGameScene(event.target.level)     end     return true end