←back to thread

293 points ulrischa | 1 comments | | HN request time: 0.213s | 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 #
echoangle ◴[] No.42174460[source]
> They were trying to detect whether it was keyboard or mouse activation

But the code shown doesn't do different stuff for Keyboard vs Mouse, it just checks if it is either one of them. Why would you do that? Which other click event types are there that you want to filter?

replies(1): >>42175205 #
1. joshtumath ◴[] No.42175205[source]
I omitted that code to keep the article simpler. We want to turn off the animation on keyboard, and move the focus to different things depending on if it's a keyboard or pointer user.