User inputs a string

I am just starting and have been trying to figure out how to allow the user to input a string by using a text box or the like. Any ideas or direction?

@BClife_brian

Here is a simple example that you can get an idea from.


function setup()
    supportedOrientations(PORTRAIT)
    str = ""
    bcolor= 0
    l=100
    r=300
    b=575
    t=625
end

function draw()
    background(30,30,0,255)
    stroke(255)
    strokeWidth(6)
    rectMode(CENTER) 
    textMode(CENTER)    
    
    fill(255)
    text("Tap button then input data",WIDTH/2,800)
    text("Press RETURN to show input in the output pane",WIDTH/2,750)    
    text("Enter value",200,650)  
  
    if bcolor == 0 then
        fill(255, 0, 0, 255)
    else
        fill(128,0,0,255)
    end

    rect(200,600,200,50)
       
    buffer = keyboardBuffer()    -- get keyed input
    
    fill(255)
    if buffer ~= nil then
        text(buffer,200,600)    -- show input as it is keyed
    else
        text(str,200,600)
    end
end

function touched()
    if CurrentTouch.x > l and CurrentTouch.x < r then
        if CurrentTouch.y > b and CurrentTouch.y < t then
            showKeyboard()
            bcolor = 1
        end
    end
end

function keyboard(key)
    if key == RETURN then    -- return key pressed
        str = buffer    -- move text into str
        hideKeyboard()
        bcolor = 0
        print(str)    -- print str in output pane
    end
end

Edit: oops, wrong thread!

.@BClife_brian - there is a textbox class provided with the example App Spritely. You can download a copy from http://codeatuts.blogspot.com.au/2012/07/tutorial-9-dependencies-libraries.html which also show how to use it or just extract it straight from the example.

.

@BClife_brian You can also look here where someone has made a nice text box class.

@Famous this thread is 2 years old… Why post a full stop?

@Luatee Lol I didn’t notice the age, I just saw it at the top due to @Famous and replied.