-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Button stays hovered on touch monitor (Win) #1470
Comments
Does your code that binds the touch pad input as a mouse disable the mouse when the touch pad is released? You need to set |
I was trying to set io.MousePos = ImVec2(-FLT_MAX,-FLT_MAX) but no success. |
Display the MousePos value and make sure it’s always -FLT_MAX one frame _after_ is released. If the openFramework binding doesn’t handle that it needs to be fixed.
|
The mouse pos is -FLT_MAX but it doesn't affect.
I tried also special addon in openframeworks which uses new WM_POINTER events to obtain more detailed information about the touch but then ImGui doesn't work anymore. |
You can't just be printing a value that you just set and that wasn't used by imgui.... You need to set And it needs to be set one frame AFTER the mouse button is released. So when the virtual mouse button is released, the position is still valid. Then it's not valid the next frame. You are trying to emulate a mouse with a touch screen this is one way to do it. PS: Also you can use ImGui::Text() instead of ofLogNotice, this is what imgui is for :) |
@sebasobotka Have you solved this on your side? |
Hi @ocornut, |
I think I got it but one thing I would like to be sure.
Here is my version of the addon. |
@sebasobotka
If you never clear the mouse position you'll get the behavior you are reporting in the first post (button stays hovered, etc.). |
This is not what I meant in my Dec 1th message and in my last message I tried to clarify it. Set io.MousePos one frame AFTER your touchUp event. |
All the rules are there. I shared my code. On Windows and openframeworks there are some issues with touches. You need to enable them. Then you can use some events like touchDown, touchUp etc. I modified the backend for using both mouse and touch events. I don't understand how to set something one frame/ two frames after, do I need to check frame number and then set something? --edit
When button is triggered there is e.g. frame nr 455, then in update loop is 456 and so on... |
I don't understand how to set something one frame/ two frames after, do I need to check frame number and then set something?
I’m not sure what to tell you... Set a boolean or integer value and test it on the next frame?
On TouchUp:
Counter = 2
Before NewFrame
If —Counter == 0 then clear MousePos
|
Yes, that's obvious. I complicated it to myself. I will check it. |
Here is two frames after - combo works, button still hovered:
You probably aren’t clearing then.
Some suggestion to actually debug your issue, because there’s no reason it shouldn’t work:
- Why not displaying io.MousePos in your imgui user interface with a call to ImGui::Text()?
- You may also enable io.MouseDrawCursor to request imgui to display a cursor that you can see to understand what’s going on.
- Also prefixing all your log statement with the current frame number ImGui::GetFrameCount() will help.
|
Hi @ocornut . But today with fresh mind ;) I got it! The frame counter needs to be set 3 frames to clear mouse position. When the touchUp event is triggered we are checking the counter in the same frame number and after ONE frame exactly we are clearing the mouse pos. The combo doesn't work and the button isn't triggered either. For counter = 3 everything works great! Here is a log for counter = 2:
Here is a log for counter = 3:
But I have another issue. What do I need to scroll combo area as shown below? |
Good point. And you can see in your GIF above for "Here is two frames after - combo works, button still hovered:" than the mouse position is NOT being cleared, that's why the button is still hovered. It's not really a question of 2 frames vs 3 frames it is that you have a bug in your flow/logic which isn't clearing the value.
You probably want to emulate a mouse wheel event, aka set io.MouseWheel based on your vertical drag delta. you also need to lock io.MousePos to the starting touch position because mouse wheel event apply to the hovered window, not the focused window. This puts a little extra burden on your side, and most annoyingly the scrolled delta won't match the exact drag distance (because it's provided in arbitrary "mouse wheel units" whereas in the case of a two fingers drag you'll ideally want movement to be exactly 1-to-1, you may adjust the scale of the value you pass, to find a nice match, but it'll feel a little dodgy). So I think it would be beneficial and make it easier for users on for touch device that I add a specific input, provided in in imgui/pixel coordinates, to trigger scrolling. You will however still need to make sure only the first touch sets io.MousePos, so when you'll drag two fingers outside the area the window keeps scrolling. Enabling TL;DR; You can follow instruction above, or wait until I add a new input and it'll become a little easier. (PS: As a side question, any reason you didn't use e.g. |
It's not visible well on my GIF but it was being cleared. But it doesn't matter today. Now I have a working version :) But why it's a bug in my flow/logic? I would like to understand it. The touchUp event and method before NewFrame() are called in the same frame number so maybe it's a better idea to remember the frame number in touchUp event and check the difference later. I will check it later.
I will wait for it ;) I have a lot of another work to do now. It's not crucial for me but it will be nice enhancement.
I am from openframeworks society and I have got some habits. It's easier sometimes to print something using OF methods than ImGui. For example in OF you have got different levels of logging and you can enable/disable them for different classes. Here is a documentation about it.
Those were my debug information. But of course, when I would need to display something for user I will use |
Either that statement is contradicting the actual data either we are not talking about the same GIF. The last GIF where the bug is visible and value of MousePos is displayed, that value it is never -FLT_MAX: I think I'll need to provide a touch demo at some point for people to use (last time I did it was on the Vita, and my code on the Switch left the mouse cursor in the same place). |
Believe me or not, this is the same movie but gif is compressed and some frames are reduced and it's not visible what I showed later. But You are right. Probably the mouse position was cleared and was overwritten later.
It would be nice to see how it should be done :) |
Button stays hovered when I touch it, using the mouse it works correctly. How can I prevent this behavior on Touch monitor (Win10)?
The text was updated successfully, but these errors were encountered: