[wxruby-users] Mouse motion example - help

Ajithkumar Warrier awarrier at berkeley.edu
Mon Mar 31 13:01:43 EDT 2008


Hi,
I am trying out this example adapted from the wxpython book, but the
mouse motion event does not seem to be captured right. What am I doing
wrong?

Thanks
warrior

# 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)}
    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}


More information about the wxruby-users mailing list