[wxruby-users] Mouse motion example - help
Ajithkumar Warrier
awarrier at berkeley.edu
Mon Mar 31 16:37:55 EDT 2008
Thanks, your suggestion worked. I missed out on the fact that I had to
bind the mouse motion to the panel and not to MyFrame. So,
@my_panel.evt_motion worked exactly as needed.
On Mon, Mar 31, 2008 at 1:28 PM, Alex Fenton <alex at pressure.to> wrote:
> Ajithkumar Warrier wrote:
> > I am trying out this example adapted from the wxpython book, but the
> > mouse motion event does not seem to be captured right.
> The mouse movement event is directed to the topmost window. So you
> either need to specify that mouse events are captured by the Frame, or
> call the event handler upon the panel which is topmost.
>
> If you think this is different to wxPython, could you post/point to the
> example you mention please?
>
> > # code below
> > require 'wx'
> >
> > class MyFrame < Wx::Frame
> > def initialize
> > super(nil, -1, "My Frame", :size => [300,300])
> > @my_panel = Wx::Panel.new(self, -1)
> > evt_motion(){ |event| on_move(event)}
> >
> Either:
>
> @my_panel.evt_motion { | e | on_move(e) }
>
> or
>
> capture_mouse
> evt_motion :on_move
>
> > Wx::StaticText.new(@my_panel, -1, :label => "Pos:", :pos => [10, 12])
> > @posCtrl = Wx::TextCtrl.new(@my_panel, -1, "",:pos => [40, 10])
> > show
> > end
> >
> > def on_move(event)
> > @pos = event.get_position
> > @posCtrl.change_value("#{@pos}")
> > end
> > end
> > Wx::App.run{MyFrame.new}
>
> cheeers
> alex
>
>
> _______________________________________________
> wxruby-users mailing list
> wxruby-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/wxruby-users
>
More information about the wxruby-users
mailing list