PDA

View Full Version : Is there an event for mouse wheel rotation?



Paul Jurczak
11-03-2013, 04:07 AM
I'm looking for an event produced by mouse wheel rotation. I found mouse_wheel_up, mouse_wheel_down and joystick_wheel. Is the last one used also for mouse wheel rotation?

rombust
11-03-2013, 08:20 AM
If you mean that you want a "get_mouse_wheel_position()" then you have to create your own.

Mouse wheels do not have an axis, they just emit clicks.



case WM_MOUSEWHEEL: id = ((short)HIWORD(wparam) > 0) ? mouse_wheel_up : mouse_wheel_down; up = true; down = true; break;


for example:

void main_code()
{
m_UpperMouseLimit = canvas.get_height();
m_WheelMousePosition = m_UpperMouseLimit /2;
Slot slot_mouse_down = (window.get_ic().get_mouse()).sig_key_down().conne ct(this, &App::on_mouse_down);
...

}

void App::on_mouse_down(const clan::InputEvent &key)
{
if (key.id == clan::mouse_wheel_up)
{
m_WheelMousePosition--;
if (m_WheelMousePosition<0)
m_WheelMousePosition = 0;
}

if (key.id == clan::mouse_wheel_down)
{
m_WheelMousePosition++;

if (m_WheelMousePosition>m_UpperMouseLimit)
m_WheelMousePosition = m_UpperMouseLimit;
}

Paul Jurczak
11-03-2013, 05:08 PM
If you mean that you want a "get_mouse_wheel_position()" then you have to create your own.

Mouse wheels do not have an axis, they just emit clicks.


The wheel on my Logitech mouse (and many other modern mice) is multi-function:
1. Push down / release.
2. Push sideways (left or right) / release.
3. Rotate (scroll) forward / backward.

From your answer, I'm assuming mouse_wheel_up means scroll forward one click, mouse_wheel_down means scroll backward one click, is that right?

rombust
11-03-2013, 07:38 PM
Yes, that is correct