Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syncing panel elements programatically #40

Open
dyarbrough93 opened this issue Apr 22, 2017 · 2 comments
Open

Syncing panel elements programatically #40

dyarbrough93 opened this issue Apr 22, 2017 · 2 comments

Comments

@dyarbrough93
Copy link

dyarbrough93 commented Apr 22, 2017

You mention here that the api is being updated allow for this and should have been available many months ago, though i still see no mention of this in the API other than controlKit.update(), which does not sync color or text fields. Is this available and just not documented? Or am i somehow missing it? This is a requirement for what I'm working on, so if I can't do this then I can't use ControlKit even though I really like what it has to offer.

@stixan
Copy link

stixan commented Sep 28, 2017

I really need an answer to this question! The fact that some components (in my case a slider) does not reflect the changes that are being performed programmatically is an absolute deal breaker.

Any chance we'll get a controlKit.update() that work on ALL components any time soon?

@milahu
Copy link

milahu commented Dec 26, 2019

the problem is, only "output components" get updated

// controlkit/lib/component/Output.js

Output.prototype.update = function () {
    if(!this._update){
        return;
    }
    this._setValue();
};



// controlkit/lib/component/StringOutput.js

StringOutput.prototype._setValue = function () {
    // ....
    var textArea = this._textArea,
    // ....
    textArea.setProperty('value', textAreaString);
    // ....
};

workaround

const config = {key: 'foo'}

const control = new ControlKit()
control.my = {} // user data
control.my.panel = control.addPanel()

// add component
control.my.panel.addStringInput(config, 'key')

// get last component
control.my.ass = control._panels.slice(-1)[0]._groups.slice(-1)[0]._components.slice(-1)[0]

// set value
const newValue = 'bar'
config.key = newValue
control.my.ass._input.setProperty('value', newValue)

// or if you know the component position
control._panels[0]._groups[0]._components[0]._input.setProperty('value', newValue)

hackaround

modify ControlKit.prototype.update = function () {
in controlkit/lib/ControlKit.js
to also update input components

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants