
MouseWheelEventArgs.Delta
Posted Monday, 14 December, 2009 - 21:56 by johnmattsson| Project: | The Open Toolkit library |
| Version: | 1.0-beta-3 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
When MouseWheelEventArgs.DeltaPrecise returns -1.0f, MouseWheelEventArgs.Delta returns 0. The code in MouseDevice.cs look like this:
public float DeltaPrecise { get { return delta; } internal set { delta = value; } } public int Delta { get { return (int)(delta + 0.5f); } }
which only do the wanted rounding when delta is positive. When delta is a negative integer, Delta will return delta + 1. The following code corrects this:
public int Delta { get { return Convert.ToInt32(delta); } }
or
public int Delta { get { return delta > 0 ? (int)(delta + 0.5f) : (int)(delta - 0.5f); } }
A seach for 0.5f in MouseDevice.cs gives the the following hits:
public int Wheel { get { return (int)(wheel + 0.5f); } internal set { WheelPrecise = value; } }
public int WheelDelta { get { int result = (int)(wheel - wheel_last_accessed + 0.5f); wheel_last_accessed = (int)wheel; return result; } }
public int Value { get { return (int)(value + 0.5f); } }
I guess these (and explicit conversions in other files) should also be changed.
/John


Comments
#1
#2
Fixed in r2566.
#3
Closing issues fixed in opentk-1.0-beta-3.