Only register mouse scroll when key is held down?
What could be improved
I want to detect if CTRL key is pressed while using the mouse wheel (for zooming)
Why should this be improved
I tried to do this using the "KeyboardEvents" and also tried overriding the GameWidget's focusNode. When any key is down - the onScroll event (ScrollDetector) is never called.
Risks
No response
More information
No response
Other
- [ ] Are you interested in working on a PR for this?
I don't think this is related to Flame, it can most likely be reproduced in pure Flutter. You could try reproducing it in Flutter and look on the Flutter issue tracker to see if you can find something about it there. If you do find something, please add it to this issue. :)
Think i found the solution. In the gesture_detector_builder.dart : applyMouseDetectors
onPointerSignal : Check for both PointerScrollEvent AND PointerScaleEvent
Test: _TransformedPointerScrollEvent#2d5e3(position: Offset(719.0, 402.0), scrollDelta: Offset(-0.0, -100.0)) _TransformedPointerScaleEvent#f1527(position: Offset(719.0, 402.0))
EDIT: You could add: void onScale(PointerScrollInfo info) {} to the ScrollDetector
If you are building for web only:
window.document.onMouseWheel.listen((event) => handleMouseWheelWeb(event));
void handleMouseWheelWeb(dynamic event) { if (event.ctrlKey) { event.preventDefault(); } }
I just upgraded to 1.18.0 but i do not see any change on the PointerScaleEvent ?
I just upgraded to 1.18.0 but i do not see any change on the PointerScaleEvent ?
I must have accidentally closed this, nobody has worked on it. Do you want to submit a PR with your fix?
Ah, re-read the issue, I don't think we should listen to scale events in the scroll detector. You should just add a detector for scaling too to your game instead.