Scirra / Construct-feature-requests

A place to submit feature requests and suggestions for Construct.
https://www.construct.net
11 stars 1 forks source link

Mouse of Canvas: "On Mouse Enter/Out" condition #344

Open XHXIAIEIN opened 2 months ago

XHXIAIEIN commented 2 months ago

Reviewed guidelines

Checked for duplicate suggestions

Summary

Currently, there seems to be no good way to check the mouse is outside the game window.

For example, if the mouse moves out of the game window, I hope to cancel some game UI to improve the user experience.

Possible workarounds or alternatives

I tried using this, but it doesn't seem to be a true trigger and will just keep listening for the event. It will trigger this event repeatedly.

window.addEventListener('mouseout', function(){
  runtime.callFunction("MouseOut")
})

window.addEventListener('mouseover', function(){
  runtime.callFunction("MouseEnter")
})

Proposed solution

"On Mouse Enter Screen" "On Mouse Out Screen"

Why is this idea important?

This may be helpful in many situations.

Additional remarks

No response

XHXIAIEIN commented 2 months ago

Another solution is to return -1 to the MouseX/Y expression when the mouse is not in the game screen.