ofxUI as displayer

Hello everybody

Is it possible to use OfxUI sliders as displayers : For instance, i would like to get data from a file and display them in form of sliders. but the sliders are used only as controllers
I would be grateful if someone help me

Hi,

First of all: please notice that ofxUI has been deprecated by the developer. And as such when starting on new projects it is advisable to take a look at the other GUI’s now available, like ofxImGui or ofxDatGui.

On-topic: When adding a widget to an ofxUICanvas you can return a pointer to the widget. You can then use this pointer to change the value(s) of the widget.

For instance, with an ofxUILabel:

//add a label
ofxUILabel myLabel = (ofxUILabel *) myCanvas->addWidget(new ofxUILabel("MY_LABEL_ID", "Hello world!", OFX_UI_FONT_MEDIUM));

//and then to change the label text
myLabel->setTextString("Hello again, world!");`

or in your case:

ofxUISlider mySlider = myCanvas->addSlider("MY_SLIDER_ID", 0, 100, 50); // init slider with value of 50
mySlider->setValue(75.f); // slider now has value of 75` 

Please note the (ofxUILabel *) bit. When using addWidget ofxUICanvas returns a pointer to the ofxUIWidget superclass when adding widgets, and to be able to call the actual widget’s functions you need to cast it to the proper subclass. This is not the case when using a subclass-specific method, like canvas->addSlider etc

Thank you so match it is working well
I have a question I would like to disable the editing mode but i don’t know which attribute can i use to do that?
For example : the mouse click (editing) has to be disabled because it is used only to display data

I found the solution : i disabled the whole canavas in which i use only the displayers widgets and in another canavas i created the controlers widgets which enabled

mycanavas->disableMouseEventCallbacks();
mycanavas->disableWindowEventCallbacks();