Comments (4)
Hi, the ControlP5propertiesCustom example works fine for me and updates variables and function calls accordingly and as expected when loading a setting. When adding a callback to a controller:
cp5.addSlider("slider")
.setRange(0,200)
.setValue(128)
.setPosition(20,100)
.setSize(20,100)
.addCallback(new CallbackListener() {
public void controlEvent(CallbackEvent theEvent) {
if (theEvent.getAction()==ControlP5.ACTION_BROADCAST) {
println("update received for", theEvent.getController().getName());
}
}
}
);
the callback event is triggered when loading a setting that contains a data entry for that particular Controller.
from controlp5.
Hello,
I managed to make it work with a toggle (the slider also works), but it doesn't work with text fields for example.
I wrote the following minimal sketch to demonstrate : when loading a previously saved value, the text in the field is changed but neither the usual callback (linked with the name) nor the callback I added are called.
import controlP5.*;
ControlP5 cp5;
Textfield portInput;
void setup() {
size(640, 480, P2D);
cp5 = new ControlP5(this);
portInput = cp5.addTextfield("changeInputPort")
.setPosition(10,40)
.setSize(40,20)
.setAutoClear(false)
.setCaptionLabel("")
.setInputFilter(ControlP5.INTEGER)
.addCallback(new CallbackListener() {
public void controlEvent(CallbackEvent theEvent) {
if (theEvent.getAction()==ControlP5.ACTION_BROADCAST) {
println("TEST");
}
}
}
);
}
public void changeInputPort(String s) {
println("input : "+s);
}
void keyPressed() {
if(key == 's'){
saveSettings("settings");
} else if (key == 'l'){
loadSettings("settings");
}
}
void saveSettings(String file){
println("Saving to : "+file);
cp5.saveProperties(file);
}
void loadSettings(String file){
println("Loading from : "+file);
cp5.loadProperties(file);
}
from controlp5.
Textfield indeed is problematic here. a manual keyboard return or calling Textfield.submit()
is necessary to trigger a broadcast event. A workaround would be to call submit()
on a textfield after properties have been loaded.
void loadSettings(String file){
println("Loading from : "+file);
cp5.loadProperties(file);
// manually call submit() to trigger a broadcast for
// Textfield portInput when loading settings.
portInput.submit();
}
from controlp5.
I will leave this to the work-around example in my previous post.
from controlp5.
Related Issues (20)
- SOME WORNG
- How to properly stop ControlP5
- How to extend the Slider
- All my buttons press themselves once on startup HOT 1
- How to change text size HOT 1
- Slider2D: Make cursorWidth height editable
- When using 2 RadioButtons it does not like the fact that addItems are the same
- How to call textbox HOT 1
- mouse-over detection not working for repsonsive window layout
- The function "tab(String)" does not exist HOT 1
- How to run a processing script using controlp5 button
- Library not working correctly in Android Mode HOT 2
- Examples don't work under Android
- Processing ControlP5 Issue - no other term for it
- slider.FLEXIBLE with more than 11 tick marks no longer aligns the pointer with the marks
- I can't use certain functions like ".setColorForeground(color)" , ".setColorCaptionLabel(color)" or ".setRadius(radius)"
- I'm trying to create a custom rounded toggle switch, but the program says the function doesn't exist
- Text doesn't delete itself after sliding.
- Can it handle multitouches
- How to Highlight text in a Textfield?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from controlp5.