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

Ability to manually select the binding view type #602

Closed Sija closed 4 months ago

Sija commented 4 months ago

ATM it seems it's not possible to override the view selected for the values passed to the Pane.addBinding function. In some cases the heuristics behind the automatic view selection (which are based on the value type and content), are not working as expected, and such ability would provide an escape-hatch, or just a more stable behaviour.

Refs #601

cocopon commented 4 months ago

You can use view: 'text' for disabling color detection:

https://tweakpane.github.io/docs/input-bindings/#color

image
Sija commented 4 months ago

I tried but it doesn't work for lists.

cocopon commented 4 months ago

Hm, can you share the code and the Tweakpane version? It works fine on the document with the latest Tweakpane.

image

https://tweakpane.github.io/docs/

p = new Tweakpane.Pane();

// without view: 'text'
p.addBinding(
  {foo: '#f00'}, 'foo',
  {
    options: {red: '#f00', blue: '#00f'},
  }
) 

// with view: 'text'
p.addBinding(
  {foo: '#f00'}, 'foo',
  {
    view: 'text',
  }
) 

// with options and view: 'text'
p.addBinding(
  {foo: '#f00'}, 'foo',
  {
    options: {red: '#f00', blue: '#00f'},
    view: 'text',
  }
) 
Sija commented 4 months ago

I was setting view: "list", with view: "text" though it works correctly, thanks!