Get mouse wheel delta GD5, before B75


#1

Hello, if you need value when you scroll with your mouse, you need “MouseWheelDelta”

It’s ok with mouse on pc/mac/linux, for touch on mobile it’s not tested, I don’t think it’s going to work, the mobile works differently.

This function is in GD but not accessible easyly.
I’ve added a function for use it as numerical expression !

Here code and below the instruction for import it in your game :

{"000kind":"GDEVELOP_Events Function_CLIPBOARD_KIND-jsBdHbLy912y8Rc","content":{"eventsFunction":{"description":"Return mouse wheel delta when we scroll","fullName":"MouseWheelDelta","functionType":"Expression","name":"E_GetMouseWheelDelta","sentence":"","events":[{"disabled":false,"folded":false,"type":"BuiltinCommonInstructions::Standard","conditions":[],"actions":[],"events":[]},{"disabled":false,"folded":false,"type":"BuiltinCommonInstructions::JsCode","inlineCode":"eventsFunctionContext.returnValue = runtimeScene.getGame().getInputManager().getMouseWheelDelta();","parameterObjects":"","useStrict":true}],"parameters":[],"objectGroups":[]},"name":"E_GetMouseWheelDelta"}}
  1. Double click for select all text
  2. Copy it with CTRL+C
  3. Go in GD5, in functions.
  4. Add a new empty function
  5. Just right click on it, and click on Paste !
  6. Now you see a new function “E_GetMouseWheelDelta”
  7. You can delete the empty function, it was just for Paste

Mouse scrolling
Mouse Wheel up/down, MouseWheelDelta() not supported ?
#2

Thanks Bouh,

This is really welcome :slight_smile:


#3

Nice, it must be included with Gdevelop as a builtin function/expression.


#4

If you use the function know that up to beta 75, it remains on the last return value.
In more recent betas, the value is reset to zero at each frame. This allows you to capture each step of the wheel.
And this is added as native condition in recent beta, this extension is no more needed.