How to add a textbox in my UI?

Hello, everyone, I am a beginner in this field. I want to create a textbox in my UI, and I can input strings. Once I have input, it could send the contents to the inner functions. And which function should I call to create this textbox? Thank you much.

the easiest is probably to use a gui addon. ofxGui comes with oF and works with ofParameters.
ofxImGui, ofxDatGui are quite popular as well.

Here is an ofxGui example

#pragma once

#include "ofMain.h"
#include "ofxGui.h"

class ofApp : public ofBaseApp{

        void setup();
        void draw();
        void onTextChange(std::string & text);

    ofxPanel _gui;
    ofParameterGroup _parameters;
    ofParameter<std::string> _textParameter;
    ofEventListener _textParameterListener;
#include "ofApp.h"

void ofApp::setup(){
//    _textParameterListener = _textParameter.newListener([this](std::string &v) { ofLogNotice() << "text changed " << v; });
    _textParameter.addListener(this, &ofApp::onTextChange);
    _parameters.add(_textParameter.set("text", "default"));

void ofApp::draw(){

void ofApp::onTextChange(std::string &text){
    ofLogNotice() << "text changed " << text;

hope that helps

Thank you, Thomas, it does work. And also I find a function named “addTextInput()” in “ofxUICanvas.h”, it also satisfies my demand. Thank you.

good to know.
ofxUI has not been updated since a few years. It probably wont compile with the current version of oF. i recommend using ofxGui, ofxImGui or ofxDatGui.