Scrolling buttons for utility app...

Hey all!

I’m playing around trying to make a utility app with some scrolling buttons for different areas of the app. I have been messing with different ways to try to get scrolling buttons to work but keep getting a failure…

Anyone figure out how to do this and want to share?

This is the code I have that starts to do it, but a lot to be desired… I have a feeling it’s going to be a lot harder than it seems.


supportedOrientations(PORTRAIT_ANY)
displayMode(FULLSCREEN)
function setup()
    rectMode(CENTER)
    
    by = HEIGHT/2
    
end

-- This function gets called once every frame
function draw()
    
    pushStyle()
    fill(255,0,0,255)
    rect(WIDTH/2,by+384,WIDTH,256)
    popStyle()
    
    pushStyle()
    fill(0,255,0,255)
    rect(WIDTH/2,by+128,WIDTH,256)
    popStyle()
    
    pushStyle()
    fill(0,0,255,255)
    rect(WIDTH/2,by-128,WIDTH,256)
    popStyle()
    
    pushStyle()
    fill(111,111,111,255)
    rect(WIDTH/2,by-384,WIDTH,256)
    popStyle()
    
    pushStyle()
    fill(111,111,0,255)
    rect(WIDTH/2,by-640,WIDTH,256)
    popStyle()
    
    pushStyle()
    fill(0,111,111,255)
    rect(WIDTH/2,by-896,WIDTH,256)
    popStyle()
    
    by=CurrentTouch.y
    
end

@Crumble Is this what you’re after or don’t I understand what you want. Slide them up or down.


supportedOrientations(PORTRAIT_ANY)
displayMode(FULLSCREEN)

function setup()
    x=100
    y=200
    dy=0
end

function draw()
    background(0)
    rect(x,y+dy,200,50)
    rect(x,y+100+dy,200,50)
    rect(x,y+200+dy,200,50)
    rect(x,y+300+dy,200,50)
    rect(x,y+400+dy,200,50)
end

function touched(t)
    if t.state==MOVING then
        dy=dy+t.deltaY
    end
end

@dave1707 Exactly, thanks much. That t.delta trick will be useful now and in the future, was trying to think of a way to calculate the change between began and ended for touch. You are the man!