What is the proper way to programatically change an input?

This issue has been tracked since 2022-10-08.

Hi all,

I have a button in my Pane that opens a dialog to choose a folder in my filesystem. I want the folder path to be stored in a text input, so that when the user presses save, this value is included in pane.exportPreset()

This is the way I managed to do it, by rummaging through the source code:

    ...
    const folder_location = pane.addInput(PARAMS, 'folder_location');

    const btn = pane.addButton({
        title: 'Select Folder',
    });
      
    btn.on('click', () => {
        (<this handles the dialog>).then(result => {
            folder_location.controller_.binding.value.rawValue = result
        });
    });

It feels like there is probably a more direct way to change the input value than .controller_.binding... but I couldn't figure it out. the value setter didn't work for me (folder_location.value = ...)

Any thought would be greatly appreciated. Thank you

cocopon wrote this answer on 2022-10-30

How about the code below:

btn.on('click', () => {
  (<this handles the dialog>).then(result => {
    PARAMS.folder_location = result;
    pane.refresh();
  });
});
cocopon wrote this answer on 2022-11-26

Feel free to reopen the issue if you have any updates.

More Details About Repo
Owner Name cocopon
Repo Name tweakpane
Full Name cocopon/tweakpane
Language TypeScript
Created Date 2016-05-10
Updated Date 2023-03-17
Star Count 2603
Watcher Count 19
Fork Count 71
Issue Count 11

YOU MAY BE INTERESTED

Issue Title Created Date Updated Date