johnmattsson's picture

MouseWheelEventArgs.Delta

Project:The Open Toolkit library
Version:1.0-beta-3
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
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

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture

#1

Status:open» confirmed
the Fiddler's picture

#2

Version:1.0-beta-2» 0.9.x-dev
Status:confirmed» fixed

Fixed in r2566.

the Fiddler's picture

#3

Version:0.9.x-dev» 1.0-beta-3
Status:fixed» closed

Closing issues fixed in opentk-1.0-beta-3.