←back to thread

293 points ulrischa | 1 comments | | HN request time: 0s | source
Show context
nightpool ◴[] No.42174146[source]
Why are you filtering for screen coordinates in the first place? What if the user is using e.g. an alternative input device that doesn't have a screen? The `click` event should be enough indication that the user has tried to activate the menu. Why reinvent the wheel?
replies(1): >>42174263 #
codetrotter ◴[] No.42174263[source]
> Why are you filtering for screen coordinates in the first place?

FTA:

> The isInvokedByMouse was checking whether the click event was invoked by a mouse or touch pointer – rather than a keyboard – by checking if the screenX or screenY coordinates were a positive number.

They were trying to detect whether it was keyboard or mouse activation, and whoever wrote it assumed that screen coordinates of mouse events would always be positive.

replies(3): >>42174434 #>>42174460 #>>42177879 #
1. Aaargh20318 ◴[] No.42177879[source]
They are breaking Curly’s Law here (https://blog.codinghorror.com/curlys-law-do-one-thing/), the screenX/Y location mean one thing: the location of the mouse event on screen. Using it for anything else is a huge red flag.