Hey everyone,
I’m missing something obvious here, but my brain is fried from working on this project for too long. I have a scroll view of buttons, but if you try to scroll while touching a button, nothing happens. The obvious answer is to use “takeFocus”. However, I still need the onRelease functionality to change scenes and I can only use onRelease = osteoView or onEvent = buttonTouch , but not both.
No idea why I can’t figure this out.
local storyboard = require "storyboard" local widget = require("widget") local scene = storyboard.newScene(); --Called if the scene hasn't been previously seen function scene:createScene( event ) -- Button Functions local function osteoView( event ) storyboard.gotoScene( "osteomyelitis", {effect="crossFade", time= 400} ) end -- Create New Group local dataGroup = self.view -- Create a ScrollView local scrollView = widget.newScrollView { left = 0, top = 0, width = display.contentWidth, height = display.contentHeight, bottomPadding = 50, id = "scrollView", horizontalScrollDisabled = true, verticalScrollDisabled = false, listener = scrollListener, hideBackground = true, } local function buttonTouch( event ) local phase = event.phase if "moved" == phase then local dy = math.abs( ( event.y - event.yStart ) ) -- If our finger has moved more than the desired range if dy \> 10 then -- Pass the focus back to the scrollView scrollView:takeFocus( event ) end end return true end -- Create Buttons local btn1 = widget.newButton { defaultFile = "images/blueBtn.png", label = "Acute & Chronic Osteomyelitis", fontSize = 16, labelColor = { default = {255}, over = {39,135,184}, }, --onRelease = osteoView, onEvent = buttonTouch, }
I have over 30 buttons in the scrollView, so right now if you’re touching any of the buttons, it won’t scroll, you have to touch between the buttons and then scroll. Need more coffee…