[wxruby-users] MouseEvent#dragging

Alex Fenton alex at pressure.to
Sun Jul 5 13:15:15 EDT 2009


Dimas Cyriaco wrote:
> I'm trying to use the dragging method of the MouseEvent, but with no
> success.
> Here is the code:
>
> require 'rubygems'
> require 'wx'
> include Wx
>
> class MyApp < App
>   def on_init
>     @frame = Frame.new(nil,-1, "Wx", DEFAULT_POSITION,
> Size.new(200,200))
>
>     evt_left_down() { | event | drag(event)}
>
>     @frame.show
>   end
>
>   def drag(event)
>     puts event.dragging
>   end
> end
>
> app = MyApp.new.main_loop
>
> I always return false, even when i'm draging the mouse.

I think it is because the event that you are capturing is evt_left_down 
- which happens as the mouse button is pressed. Dragging implies motion, 
so it it's not relevant. I would try capturing evt_motion and see if it 
works as you expect there.

a


More information about the wxruby-users mailing list