Forums Archived

The forums are being archived. See this topic for more information.

Help with Events::MouseMoved

Get help and support with Rubygame

Help with Events::MouseMoved

Postby moinkers » Tue Feb 02, 2010 6:56 pm

Anytime I catch the Events::MouseMoved event the event.buttons array appears to think all buttons are pressed. It always returns:
mouse_leftmouse_middlemouse_rightmouse_wheel_upmouse_wheel_down
even if I'm not holding down any buttons.

Am I doing something wrong?
moinkers
 
Posts: 2
Joined: Tue Feb 02, 2010 6:47 pm

Re: Help with Events::MouseMoved

Postby moinkers » Tue Feb 02, 2010 8:50 pm

the _convert_mousemotionevent( ev ) function in events.rb uses a mask that doesn't seem to work right.

I don't understand why it doesn't work exactly but changing the mask from this:
btns << :mouse_left if( mods & SDL::BUTTON_LMASK)
to this:
btns << :mouse_left if( (mods & SDL::BUTTON_LMASK) != 0 )

seemed to fix the problem.
moinkers
 
Posts: 2
Joined: Tue Feb 02, 2010 6:47 pm

Re: Help with Events::MouseMoved

Postby shawn42 » Tue Feb 02, 2010 9:01 pm

It has to do with ruby's definition of true. The bitmask coming from C land is probably returning 0 if it doesn't match. In Ruby, 0 counts as "true". Only nil and false count as "false". This differs from C land where if(0) would be "false".

Hope that helps a little,
User avatar
shawn42
 
Posts: 109
Joined: Tue Feb 10, 2009 8:22 pm

Re: Help with Events::MouseMoved

Postby jacius » Tue Feb 02, 2010 11:13 pm

Ah, yes, this is a bug in Rubygame from when I ported the C code to Ruby. Nice catch. I'll fix this up right away.
User avatar
jacius
Site Admin
 
Posts: 131
Joined: Fri Feb 06, 2009 11:13 pm


Return to Help & Support

Who is online

Users browsing this forum: No registered users and 1 guest

cron