aframe-gui icon indicating copy to clipboard operation
aframe-gui copied to clipboard

No text displaying in a-gui-input's

Open DaryllConway opened this issue 5 years ago • 9 comments

I've spent a whole day trying to get text to display in an a-gui-input but it's just constantly blank no matter what I do, can you see where I'm going wrong?


` <a-gui-flex-container flex-direction="column" justify-content="center" align-items="normal" component-padding="0.1" opacity="0.7" width="3.5" height="4.5" position="2 2.5 -6" rotation="0 0 0" gui-item="" geometry="" material="" gui-flex-container="">
    	<a-gui-input id="test_input" width="4" height="0.7" onclick="testInputAction" value="Testing" font-size="160px" font-color="#212121" border-color="#212121" border-hover-color="#424242" background-color="#FAFAFA" hover-color="#F5F5F5" active-color="#FFEB3B" gui-interactable="" gui-item="" geometry="" material="" role="input" gui-input="" position=""></a-gui-input>
    </a-gui-flex-container>`

DaryllConway avatar Nov 01 '20 18:11 DaryllConway

I got blank text too. the console shows something like this though. could it be the source of the problem ?

image

sulaemansantoso avatar Dec 03 '20 08:12 sulaemansantoso

Either of you ever figure this out? @sulaemansantoso @daryllconway

kylebakerio avatar Dec 27 '20 16:12 kylebakerio

It isn't documented in the readme as far as I can tell, but looking into the example code, it's pretty straightforward:

      <a-gui-flex-container
      id="startup-menu555"
      flex-direction="column" 
      justify-content="center" 
      align-items="normal" 
      component-padding="0.1"
      opacity="0.7" width="4" height="5"
      position="-6 1.5 -8" 
      rotation="0 -90 0"
      >
        <a-gui-input
         id="test_input555"
         width="3" height="0.7"
         onclick="alert('hi')"
         value="Starting value"
         font-size="160px"
         font-color="red"
         border-color="#212121"
         border-hover-color="#424242"
         background-color="#FAFAFA"
         hover-color="#F5F5F5"
         margin=".15 0 0 0"
         active-color="#FFEB3B"
        >
        </a-gui-input>
      </a-gui-flex-container>
var textField = document.querySelector("a-gui-input");
textField.components['gui-input'].appendText('adding text');
setTimeout(() => {alert('will delete text now'); textField.components['gui-input'].delete();}, 10000)

Note that "delete" deletes one character, not whole input.

kylebakerio avatar Jan 04 '21 20:01 kylebakerio

a little more digging in the source for gui-input shows that

textField.setAttribute('gui-input', 'text', "helloooo");

works for updating the text more than one char at a time

however, initial text values seem broken to me for now--if I figure out something I'll add it here, and hopefully eventually update the docs.

kylebakerio avatar Jan 04 '21 21:01 kylebakerio

(To be clear, the 'starting value' feature does seem broken, though.)

kylebakerio avatar Jan 08 '21 12:01 kylebakerio

Yes you're right, the issue is the starting value. but i haven't tried to look more into it

sulaemansantoso avatar Jan 13 '21 05:01 sulaemansantoso

i think this is due to a wrong variable name in input.js

image

whereas the schema for the component is not inputText but text

image

sulaemansantoso avatar Jan 13 '21 11:01 sulaemansantoso

There are many small things like that. I'm grateful to this library, but it needs a second pass of polish. It feels like someone created a full library beta version and threw a ton of components at the wall, but didn't check everything everywhere. Shows great promise, just needs minor tweaks, in the meantime takes workarounds like the one I mentioned. (As in, that's right, initial text value doesn't work, but you can populate initial text right after element creation with JS instead for now.)

I know there's a big update coming with some important, very nice changes. Once that lands, I'm hoping to actually take on a bunch of those small updates and documentation fixing. I've been developing my menu system in my app with this.

kylebakerio avatar Jan 13 '21 13:01 kylebakerio