-
Notifications
You must be signed in to change notification settings - Fork 144
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
Allow user to choose how mouse position is computed in mouse events #62
base: develop
Are you sure you want to change the base?
Conversation
I completely agree with the problem you've described here, but I worry about needing to make additional breaking changes in the future to support new use cases. For example, what about modifier keys? I'm not sure it's sustainable to try to foresee what the user might need. Do you have any thoughts on how we can extend this to a more general interface? |
I totally see your point. I guess if we want to solve the problem once and for all then all mouse related events should return an e <- domEvent Mousemove el
let xyOffset = (mouseEventOffsetX &&& mouseEventOffsetY) <$> e (Similarly, Ideally, we wouldn't need to recreate the MouseEvent datatype, but instead leverage on the functions that are already in ghcjs-dom by making them available to the user. Let's say we have a monadic fmap for events, then I could for example write e <- domEvent Mousemove el -- e :: ev, IsMouseEvent ev
xOffset <- fmapM (liftIO . getOffsetX) e But this is probably less user friendly than the first version |
Yep, I think that might be the way to go eventually! We can't do IO directly when mapping over Events, since that would make Reflex non-deterministic, but the user can use performEvent as necessary. I think an approach like the purescript-halogen one might be best. |
50dc715
to
aa86b10
Compare
The diff now shows how the halogen approach might look like. Next step would be to populate the records for the different event result types. Interestingly, for example |
Okay, I added the properties that I think make sense. Some remarks:
|
Usage would be:
Drawback is that it breaks usage of
Mousemove
,Mouseup
andMousedown
.An alternative would be to introduce event types like
MousemoveOffset
etc. But then it's not clear whyMousemove
should yield(e.clientX, e.clientY)
...