Parameter value not updating.

Hi!

The parameter maximum value (par1MaxVal) is not updating after rotating the screen or hiding the inspector.

The parameter.number must be in the setup ,but setup is just evaluate once.

Here is the code :

function setup()
    
    xr = 50   -- rect size 
    par1MaxVal = WIDTH-xr

    parameter.number("xs", 0,par1MaxVal,500,function(n) print("X = "..n) end )   

end


function draw()
    
    background(40, 40, 50)

    -- displays screen size at bottom right
    font("Futura-CondensedExtraBold")
    fontSize(15)
    fill(255, 255, 255, 146) 
    textAlign(CENTER)
    textWrapWidth()
    text(WIDTH .. "    " .. HEIGHT,WIDTH-40,20) 
    
    -- draw rectangle
    rect(xs,HEIGHT/2,xr,xr)
end

Have a good time

@shem Try this.

function setup()
    xr = 50   -- rect size 
    wh=WIDTH
    par1MaxVal = WIDTH-xr
    parameter.clear()
    parameter.number("xs", 0,par1MaxVal,500,function(n) print("X = "..n) end )   
end

function draw()
    background(40, 40, 50)
    -- displays screen size at bottom right
    font("Futura-CondensedExtraBold")
    fontSize(15)
    fill(255, 255, 255, 146) 
    textAlign(CENTER)
    textWrapWidth()
    text(WIDTH .. "    " .. HEIGHT,WIDTH-40,20) 
    -- draw rectangle
    rect(xs,HEIGHT/2,xr,xr)
    if wh~=WIDTH then
        setup()
    end
end

You can also use the function ‘orientationChanged’ to detect when the user rotates the screen, to update the parameters.

function orientationChanged(newOrientation)
    ...
end

Thanks Dave .