Jump to content

Mouse wheel question


aiaf
 Share

Recommended Posts

Hi,

 

Im getting the mouse wheel index(in the main loop) and use this in a menu:

selectedDirection = (int)window->GetMousePosition().z;

 

There is a function, or other way, that detects that Wheel moved ?

 

Something like:

if(window->MouseWheelHit()) {

do something

}

I made this with Leadwerks/UAK:

Structura Stacky Desktop Edition

Website:

Binary Station

Link to comment
Share on other sites

You have to check the mouse position Z component

 

class SomeClass
{
float _lastMZ;
...

void Init()
{
 _lastMZ = Window::GetCurrent()->GetMousePosition().z;
}

void UpdateWorld()
{
 auto mz = Window::GetCurrent()->GetMousePosition().z;
 if ( mz != _lastMZ )
 {
		 // mouse wheel moved
		 // distance is mz-_lastMZ
		 _lastMZ = mz;
 }
}
};

  • Like 1
  • Upvote 1

AV MX Linux

Link to comment
Share on other sites

class MouseSensorListener
{
public:
   virtual void onmousewheelHit( float distance ) = 0;
};
class MouseSensor
{
private:
   float _lastMZ;
   MouseSensorListener _listener;
public:
   void init()
   {
    _listener = nullptr;
    _lastMZ = Window::GetCurrent()->GetMousePosition().z;
   }
   void register( MouseSensorListener* listener )
   {
    _listener = listener;
   }
   void unregister()
   {
    _listener = nullptr;
   }
   void update()
   {
    auto mz = Window::GetCurrent()->GetMousePosition().z;
    if ( mz != _lastMZ )
    {
	    // mouse wheel moved
	    // distance is mz-_lastMZ
	    if( _listener )
	    {
	    _listener->onmousewheelHit(mz-_lastMZ);
	    }
	    _lastMZ = mz;
    }
   }
};
class SomeClass :
   public MouseSensorListener
{
public:
   void init( MouseSensor* sensor )
   {
   sensor->register(this);
   }
   void onmousewheelHit( float distance )
   {
    // Mouse wheel moved 'distance'
   }
};

AV MX Linux

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...