How to solve HTML build bug for DefChat asset

I built DefChat in HTML and it worked perfectly fine. When I bundle it, although, it seems to bug up the string value. When pressing spaces, it doesn’t respond. It also puts ‘~’ at the end of the messages at times…

I’m very curious as to why this is. I left the HTML demo up on the asset if you’d like to see what I’m talking about.

Well, it looks as though the return key gets picked up as a normal key press and added to the end of the string. You need to handle this and ignore the return key. Also, I noticed that spacebar doesn’t do anything. I expected to be able to write multi-word input.

Very strange. Is this a bug in the HTML build? Enter is not exactly a “text” trigger. My triggers are setup as so:

  • key_enter: “enter”
  • key_backspace: “backspace”
  • text: “text”

Yes, I meant what you said. Not that the build crashes, but that I don’t get input from spacebar. Along the same problem as above, is spacebar not considered a “text” trigger in the HTML build?

I uploaded the new build and tried to tackle the tilde character being inserted at the end. I don’t think it’s because of the enter key. I simply removed it as a usable character by saying:

if action_id == hash("text") then
... -- inside "text" input responder
    if action.text ~= "~" then -- if the text is "~", do not continue
    ...

This means that it’s not being inserted into the string through the “text” trigger. But, alas, it still appears. I don’t know how else it would get there.

I also tried fixing the spacebar issue by forcing the trigger:

  • key_spacebar: “text”

But the engine complained. “Cannot concatenate a nil value, etc etc etc.” Essentially, the action.text was nil. How do I receive spaces in HTML then?

Detect spacebar as a normal input action event with action.released and then add a " " to the end of the string in HTML5 builds?

1 Like

That would work. It would just require a simple if statement a setting action.text to " " like you said, just before it went through the concatenation process and etc.

Now I just need to fix the tilde bug.

The main thing I want to figure out is if these are HTML build bugs, or whether it’s an error on my part.

I did a test in my Gooey lib on the text input and I get the same result for HTML5. I took a look at action.text and in HTML5 builds the return key will generate a “\r”. Check action.text and ignore if it’s equal to “\r”.

1 Like