britzl / gooey

Defold GUI system
MIT License
150 stars 22 forks source link

Input state machine doesn't include 'released_now' or 'clickable' fields on last frame #56

Closed base-thomas closed 3 years ago

base-thomas commented 5 years ago

I just started playing around with this library recently (using release 7.5.2), am currently trying to incorporate a basic text input node in my project (on android). For some reason though, on the final touch frame, the 'released_now' and 'clickable' fields that would indicate a completed click do not show up.

Here's the relevant portion of console feedback: (pprinting the input table each frame)

DEBUG:SCRIPT: { --[[0xad34a090]] pressed_now = false, node = @(0, -24, 0), long_pressed = true, current_text = "", set_visible = function: 0xad34a180, refresh_fn = function: 0xaed03a10, marked_text = "", out_now = false, total_width = 0, set_long_pressed_time = function: 0xaed057d0, text_width = 0, long_pressed_time = 1.5, marked_text_width = 0, clicked = false, enabled = true, set_text = function: 0xad34a100, text = "", consumed = false, refresh = function: 0xad34a140, over = false, empty = true, deselected_now = false, over_now = false, keyboard_type = 0, released_now = false } DEBUG:SCRIPT: { --[[0xad34a090]] pressed_now = false, node = @(0, -24, 0), long_pressed = true, current_text = "", set_visible = function: 0xad34a180, refresh_fn = function: 0xaed03a10, marked_text = "", out_now = false, total_width = 0, set_long_pressed_time = function: 0xaed057d0, text_width = 0, long_pressed_time = 1.5, marked_text_width = 0, clicked = false, enabled = true, set_text = function: 0xad34a100, text = "", consumed = false, refresh = function: 0xad34a140, over = false, empty = true, deselected_now = false, over_now = false, keyboard_type = 0, released_now = false } DEBUG:SCRIPT: { --[[0xad34a090]] pressed_now = false, node = @(0, -24, 0), long_pressed = true, current_text = "", set_visible = function: 0xad34a180, refresh_fn = function: 0xaed03a10, marked_text = "", out_now = false, total_width = 0, set_long_pressed_time = function: 0xaed057d0, text_width = 0, long_pressed_time = 1.5, marked_text_width = 0, enabled = true, set_text = function: 0xad34a100, text = "", refresh = function: 0xad34a140, over = false, empty = true, deselected_now = false, over_now = false, keyboard_type = 0 }

I'm kind of surprised nobody else has had this issue, as it's a pretty big roadblock for me. It's possible I'm doing something wrong but I don't know what that would be. Can anyone else replicate this issue?

britzl commented 5 years ago

Hmm, this could be a problem on mobile. When I tested on desktop using one of the examples (kenneyblue.gui_script) i got clicked=true and released_now=true in the same frame. Can you verify if you get the same behavior when you test on desktop?

base-thomas commented 5 years ago

Still getting the same behavior with desktop/mouse, despite making a new blank project to test with. I uploaded it to the cloud if you'd like to take a look: project id #153589

britzl commented 5 years ago

Could you please zip the project and share it here (exclude .git and build folder)?

base-thomas commented 5 years ago

Sure, sorry: testapp.zip

I must be doing something wrong here? Just no idea what it would be

britzl commented 5 years ago

I added this:

print(input.clicked, input.released_now)

To the top of your update_input(input) function. When the mouse button is released I see:

DEBUG:SCRIPT: true  true
DEBUG:SCRIPT: released!

Isn't that what you expected to see?

base-thomas commented 5 years ago

Odd, this is not the behavior I'm continuing to experience. Doing what you did (on desktop) gives me the following in console:

INFO:DLIB: SSDP: Started on address __ DEBUG:SCRIPT: false false DEBUG:SCRIPT: Touch! DEBUG:SCRIPT: false false DEBUG:SCRIPT: nil nil

So the question is.... what could be different on my end? Weirdly enough I did experience the correct functionality for one of my earlier builds yesterday but was not able to replicate it a second time. As far as I can remember I didn't change anything notable before/after it was working though...

britzl commented 5 years ago

Very strange. Which OS are you using? Is it a standard mouse you're using?

base-thomas commented 5 years ago

Windows 10 Pro 64bit Editor version 1.2.141 Was using bluetooth mouse, same result with trackpad and touchscreen

britzl commented 5 years ago

1.2.141? That is a very very old version of Defold. We are releasing 1.2.161 tomorrow. Why are you using such an old version?

base-thomas commented 5 years ago

It was the one I downloaded a few months ago when I started using defold. I installed and tested 1.2.160 and am still getting the same functionality across all my projects though.

base-thomas commented 5 years ago

Ok wait, I think I figured it out!

The nil nil case only occurs when the touch happens outside the bounds of the text node, I had assumed that the state machine would still track press/release status regardless of where that touch was on the screen, but it does not. Is this the intended functionality? I feel like it would be more robust to update these fields regardless, for example if the input box background is larger than the text node, the user might touch what looks like the node but won't trigger the relevant input function.

I went back into my projects and tested further, more specifically the nil case only occurs if there has not been a completed touch originating in the input node. Once that happens touches outside the node show 'released_now' and 'clicked' as false instead of nil

Thanks for your attention and help with my issue, as well as for making this library! Now that I understand what is going wrong I can move forward on my project once again.

britzl commented 5 years ago

If the mouse down event happens inside the node but the released event happens outside then I would expect clicked to be false and released_now would be true.

britzl commented 3 years ago

Not a bug. Closing.