module TkMovable
Public Instance Methods
moving_do_move_obj(_x, _y)
click to toggle source
# File lib/a-tkcommons.rb, line 114 def moving_do_move_obj(_x, _y) _x = TkPlace.info(@moved_obj_m)['x'] + _x - @x0_m _y = TkPlace.info(@moved_obj_m)['y'] + _y - @y0_m @moved_obj_m.place('x'=>_x, 'y'=>_y) end
moving_do_press(_x, _y)
click to toggle source
# File lib/a-tkcommons.rb, line 109 def moving_do_press(_x, _y) @x0_m = _x @y0_m = _y end
start_moving(_moving_obj=self, _moved_obj=self)
click to toggle source
# File lib/a-tkcommons.rb, line 95 def start_moving(_moving_obj=self, _moved_obj=self) @x0_m = 0 @y0_m = 0 @moving_obj_m = _moving_obj @moved_obj_m = _moved_obj @moving_obj_m.bind_append("B1-Motion", proc{|x, y| moving_do_move_obj(x,y)},"%x %y") @moving_obj_m.bind_append("ButtonPress-1", proc{|x, y| moving_do_press(x, y)},"%x %y") end
stop_moving()
click to toggle source
# File lib/a-tkcommons.rb, line 104 def stop_moving @moving_obj_m.bind_remove("B1-Motion") @moving_obj_m.bind_remove("ButtonPress-1") end