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

Hover state doesn't update if there are no mouse move events #220

Closed
nimble0 opened this issue Aug 17, 2021 · 9 comments
Closed

Hover state doesn't update if there are no mouse move events #220

nimble0 opened this issue Aug 17, 2021 · 9 comments
Labels
enhancement New feature or request
Milestone

Comments

@nimble0
Copy link

nimble0 commented Aug 17, 2021

Reproducing:

  • Load the animation sample.
  • Position the mouse over the "Events (press arrow keys)" box. The box will become highlighted from the hover style.
  • Don't move the mouse.
  • Press arrow keys to move the box.

Result: The box will remain highlighted even when the cursor is no longer over the box.

It can cause some less innocuous bugs too; I encountered it while trying to temporarily block input in a key mapping screen.

A simple fix is to make sure to call ProcessMouseMove before every update (the arguments can be the same as last update).

@mikke89
Copy link
Owner

mikke89 commented Aug 17, 2021

Right, yes, this also happens with animations if the hovered element moves away from the mouse cursor. Another case is when the element under the cursor is removed, and new ones are constructed. I've noticed this may break scrolling until after the mouse has moved again, probably because we need to re-establish a new hover element. This is noticeable sometimes in the debugger.

I'd like to know more about your issue with your key mapping screen and how that is affected, could you add some more details?

I'm concerned the proposed fix may cause some unexpected behavior, in particular for users not using mouse cursors or intentionally not providing any mouse input. Hm, actually, now after looking over the code, I see that we don't send a mouse move event if the position is the same, so this might be a viable approach. Although we do send out drag events, not sure if this is an issue.

In any case we should think some more about possible ways this might cause issues before we push these changes.

@nimble0
Copy link
Author

nimble0 commented Aug 19, 2021

Oh, I meant that as a user side fix.

I'd like to know more about your issue with your key mapping screen and how that is affected, could you add some more details?

I have a list of buttons corresponding to actions that can be mapped. To map an action you click the button for that action and the page starts waiting for an input (key press or mouse button press). I don't want the input to do whatever action it would normally do so I use "pointer-events: none" to block them while waiting for input. This works fine unless the user doesn't move the mouse and then presses the left mouse button. In this case it still registers the click on the button despite "pointer-events: none" and starts waiting for input again.

@mikke89
Copy link
Owner

mikke89 commented Aug 20, 2021

Ah, I see. It could be a place to start in any case.

Thanks for your very descriptive example.

One idea I have for a solution is to do something equivalent to ProcessMouseMove during Context::Update. However, we also add a new function Context::ProcessMouseOut or similar which disables this automatic processing to avoid unintended (de)focusing. The automatic processing resumes after the user calls Context::ProcessMouseMove.

Any thoughts or other ideas?

@mikke89 mikke89 added the enhancement New feature or request label Aug 20, 2021
@nimble0
Copy link
Author

nimble0 commented Aug 24, 2021

Sounds good to me.

@mikke89 mikke89 added this to the 5.0 milestone May 24, 2022
@xland
Copy link

xland commented Jun 10, 2022

@mikke89

How about this issue's progress?
It's really important to me.
Is it possible to fix it in 4.x?
Thanks very much.

@mikke89
Copy link
Owner

mikke89 commented Jun 10, 2022

Yeah, it is planned for RmlUi 5.0, I'll try to prioritize this in the near feature.

I won't backport any new features, if you really need it in 4.x you will have to port the changes yourself. There aren't really any significant breaking changes (at least yet), so you might want to consider using the RmlUi master branch for your project.

@xland
Copy link

xland commented Jun 10, 2022

Thanks for your reply.
I hope to see it resolved on the master branch soon.

mikke89 added a commit that referenced this issue Jun 21, 2022
…eLeave()' to remove hover states and prevent them from updating, see #220.
@mikke89
Copy link
Owner

mikke89 commented Jun 21, 2022

Hey.

I've made an effort at implementing this now.

  • The hover state of any elements under the mouse will now automatically be updated during Context::Update().
  • Added Context::ProcessMouseLeave() which ensures that the hovered state is removed from all elements, and stops the context update from automatically hovering elements.
  • When Context::ProcessMouseMove() is called next the context update will start updating hover states again.
  • I've also updated all the backends to handle mouse leave events.

Seems to work well for me for now, however it does require more testing in case of unintended consequences. Let me know how it goes, cheers!

@xland
Copy link

xland commented Jun 22, 2022

I test it on Windows 10,it works (use opengl2 as default).
Thanks very much.

@mikke89 mikke89 closed this as completed Nov 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants