cocopon / tweakpane

:control_knobs: Compact GUI for fine-tuning parameters and monitoring value changes
https://tweakpane.github.io/docs/
MIT License
3.41k stars 85 forks source link

v4 - refresh no longer working #570

Closed bcorporaal closed 10 months ago

bcorporaal commented 10 months ago

I am trying to migrate code from Tweakpane v3 to v4. All is working well, except for the refresh function. The code using it that was working for v3 no longer works. Specifically, nothing happens.

Here is an example panel I'm working on:

Screenshot 2023-09-03 at 17 48 08

In the Colors section, clicking the arrows or the rnd buttons changes the palette value and triggers a refresh. Previously then the palette dropdown would update and the visualization would redraw. With v4 nothing happens. No changes, no errors.

Digging into the Tweakpane code and adding a few log statements, it seems that in the refresh function (line 1708) the children array it tries to iterate only has 1 child and that has isRefreshable = false. Given that there are multiple inputs and taps in this instance, I would imagine it needs to iterate more than 1 child.

Again, this all worked with v3, so I'm not sure what is going on.

cocopon commented 10 months ago

This small test code works fine in my environment:

const PARAMS = {someProp: 1};
const pane = new Pane();

// Adding some bindings
pane.addBinding(PARAMS, 'someProp');
pane.addBinding(PARAMS, 'someProp', {options: {'foo': 1, 'bar': 2}});

// Update the value outside the pane
PARAMS.someProp = 2;

// Refresh the pane
pane.refresh();
// or, pane.children[i].refresh() also works fine

It seems that more information about your environment is needed to reproduce the problem. Sharing a code snippet or a minimal environment would be helpful.

bcorporaal commented 10 months ago

Thanks for your input. The pane.children[i[.refresh() comment got me thinking and I got it working. As you can see in the screenshot, I have multiple tabs. If instead of pane.refresh(), I use pane.pages[0].refresh(), it works for me.

Not sure if this is the intended behavior, but for me this works.

If you're curious, you can see it in my code for Toko, a library to extend p5.js. Here line 29 and onwards, I set up the 3 buttons, and line 55 is where I had to change it. (pane.tab is a shortcut to tweakpane.pages[0]).

cocopon commented 10 months ago

Thank you for the details! I found the cause and created a new issue: #571

cocopon commented 10 months ago

Fixed in 4.0.1.