Skip to content
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

Mouse down event not registered properly when there is no mouse motion #20

Open
uberyoji opened this issue Dec 5, 2019 · 5 comments
Open

Comments

@uberyoji
Copy link

uberyoji commented Dec 5, 2019

I recently ported the code to a project I am working on the nintendo switch. Since I am using touchscreen, there are no motion message being sent (unless when dragging). Motion occurs only when a touch is inputed.

Seems controls need to be hovered first thru motion before mouse down is processed properly.
I tried to debug it a little. I believe the problem occurs in mu_update_control when the context hover id is set.

To reproduce the issue just disable the processing of motion in the sdl message handler. You'll notice you need to click several time to get a proper mouse down.

I'll continue to investigate, let me know if you have some ideas.

@uberyoji
Copy link
Author

uberyoji commented Dec 5, 2019

I think I have a better understanding now. ctx->hover_root is not set on mousedown and the mu_mouse_over called from mu_update_control fails because in_hover_root returns false.
Not sure how to fix it yet though.

@uberyoji
Copy link
Author

uberyoji commented Dec 5, 2019

Ok I think I found the issue. The problem lies with ctx->last_hover_root. Since it is null at the beginning, the first move and click will be lost. This never happens when we send down mouse moves every frame as ctx->last_hover_root will be quickly set to something valid. I think I will fix my problem by sending fake mouse moves at the window header coordinates.
I wonder if this behavior could also affect focus state.

@uberyoji
Copy link
Author

uberyoji commented Dec 7, 2019

Got the fix! Touchscreen now works perfectly.

In microui.c changed line 654:
if (mouseover /*&& !ctx->mouse_down*/) { ctx->hover = id; }

In microui.c added a new line at 1042:
if( ctx->last_hover_root == 0 ) ctx->last_hover_root = cnt;

@ericoporto
Copy link

@uberyoji do you still have the modified microui.c somewhere? I think the lines changed or I am not sure if I am looking in the right place. Do you remember if this solved in Switch but broke the mouse?

@pythonmcpi
Copy link

@ericoporto The most recently commit available when uberyoji wrote their comment is c988730 (Committed on Oct 6, 2019).

If you have a local copy of the repository (from git clone), you can run git checkout c988730 to visit that commit. You can run git checkout - to go back to the current commit. (If you've made any local commits after running the first command, check this stackoverflow answer before you go back or you may lose your changes.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants