teichgraf's picture

Mouse & me again

The Mouse.WheelDelta will never be zero if the wheel was used ones. After that the value is 1 or -1. I think the WheelDelta should be reseted when the mouse wheel isn't used, so it's value is 0, instead of 1 or -1.

And how can I test if no mouse button is pressed? I am searching for something like Mouse[MouseButton.None] or !Mouse.Pressed. At the moment I need to test if every button is not pressed: !Mouse[MouseButton.Left] && !Mouse[MouseButton.Right] .... Or Am I missing something?


Comments

Comment viewing options

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

The Mouse.*Delta functions do not work correctly right now, but I'm working on a fix.

Can't you just assume that no button is pressed by default?

bool button_pressed = false;
if (Mouse[MouseButton.Left])
{
    // do something
    button_pressed = true;
}

Or is there a use case that's not covered by this?

teichgraf's picture

Thanks for the reply.

The code you posted above would surely work, but one needs an extra button_pressed variable.

Actually I need this functionality for Keyboard. I am doing something like this in UpdateFrame:

if(Mouse[MouseButton.Left])
{   
   Func1();
}

And In the MouseButtonUp:

if(Mouse[MouseButton.Left] && Keyboard[Key.CtrlLeft])
{   
   Func2();
}

So when I press the left mouse button and hold Key.CtrlLeft, Func2() and Func1() are called. But I just want Func2() to be executed.
A way to achieve this, would be a modified UpdateFrame:

if(Mouse[MouseButton.Left])
{
   if(Keyboard[Key.CtrlLeft])
   {   
       // NOP
   }
   else
   {
       Func1();
   }
}

But in my opinion it is more elegant to write something like this in UpdateFrame:

if(Mouse[MouseButton.Left] && Keyboard[Key.None])
{   
   Func1();
}
Mincus's picture

Edit: Nevermind, didn't read the problem correctly.