dataarts / dat.guiVR

A flexible graphical user interface for changing variables within WebVR.
https://workshop.chromeexperiments.com/examples/guiVR/
Apache License 2.0
311 stars 50 forks source link

vive nested folders: clicked folder stays focused and prevents other presses #92

Open ManuelGraf opened 7 years ago

ManuelGraf commented 7 years ago

when I call

inputObject.pressed(true)

the folder which i opened stays highlighted and prevents any further clicks to other folders and/or buttons.^

detaled information:

i am creating my gui recursively like in the nested example:

objects.forEach(function (element) {
      this.addGUIElement(this.gui,element);
    }, this);

    var inputObject = dat.GUIVR.addInputObject(this.gamepad.object);
    this.scene.add(inputObject);

    window.addEventListener('viveControllerThumbpadPressed', (e) => {
      inputObject.pressed(true);
    });

 addGUIElement(folder, subtree) {
    if (subtree.children) {
      console.log('creating subfolder %s', subtree.label);
      const newFolder = dat.GUIVR.create(subtree.label || '');
      newFolder.name= subtree.label;
      subtree.children.forEach(function (element) {
        this.addGUIElement(newFolder, element);

      }, this);
      folder.addFolder(newFolder);

    } else {
      var setting = {
        travel: () => {
          console.log(subtree.label + 'pressed');
        }
      }
      var btn1 = folder.add(setting, 'travel');
      btn1.name(subtree.label);
      console.log('created button %s', subtree.label);
      return;
    }
  }
xinaesthete commented 7 years ago

I'll try to remember to check that soon. Maybe ping me if you don't hear anything by mid next week. You might also want to try with my fork https://github.com/xinaesthete/dat.guiVR/tree/ImageButton is a branch with a few new (not well documented) features added but it should do the standard stuff fine and may well have bug fixes relevant to this, I don't remember off the top of my head.

Anyway, that's the version I was using when I was last actively working with this and I certainly had some nested folders behaving reasonably with Vive.

ManuelGraf commented 7 years ago

@xinaesthete Actually, your fork was the first one I tried out due to the ImageButton functionality. I would love to use it, but it's not possible without any documentation.

For Example, I can't use the addFolder function because it is missing in your branch. If you can show me an example of how you used it, this would be great!

xinaesthete commented 7 years ago

@ManuelGraf https://github.com/xinaesthete/dat.guiVR/blob/ImageButton/examples/imagebutton.html is all working here (non-Vive example, but Vive stuff should be working as well). Admittedly that example doesn't cover quite 100% of new features, doesn't have much (anything) in the way of comments, and the interface for some of the new stuff is liable to change at some point, but it is using addFolder and image buttons / grids as well as colour pickers and text box input.

xinaesthete commented 7 years ago

I've included that example in the examples index page as "Simple ImageButton Example".

xinaesthete commented 7 years ago

@ManuelGraf is it possible that you accidentally checked out the master branch of my fork, rather than ImageButton? That will be behind.