Module: TkMovable
- Included in:
- TkFloatTitledFrame, TkFrameAdapter
- Defined in:
- lib/a-tkcommons.rb
Instance Method Summary collapse
- #moving_do_move_obj(_x, _y) ⇒ Object
- #moving_do_press(_x, _y) ⇒ Object
- #start_moving(_moving_obj = self, _moved_obj = self) ⇒ Object
- #stop_moving ⇒ Object
Instance Method Details
#moving_do_move_obj(_x, _y) ⇒ Object
89 90 91 92 93 |
# File 'lib/a-tkcommons.rb', line 89 def moving_do_move_obj(_x, _y) _x = TkPlace.info(@moved_obj)['x'] + _x - @x0 _y = TkPlace.info(@moved_obj)['y'] + _y - @y0 @moved_obj.place('x'=>_x, 'y'=>_y) end |
#moving_do_press(_x, _y) ⇒ Object
84 85 86 87 |
# File 'lib/a-tkcommons.rb', line 84 def moving_do_press(_x, _y) @x0 = _x @y0 = _y end |
#start_moving(_moving_obj = self, _moved_obj = self) ⇒ Object
70 71 72 73 74 75 76 77 |
# File 'lib/a-tkcommons.rb', line 70 def start_moving(_moving_obj=self, _moved_obj=self) @x0 = 0 @y0 = 0 @moving_obj = _moving_obj @moved_obj = _moved_obj @moving_obj.bind_append("B1-Motion", proc{|x, y| moving_do_move_obj(x,y)},"%x %y") @moving_obj.bind_append("ButtonPress-1", proc{|e| moving_do_press(e.x, e.y)}) end |
#stop_moving ⇒ Object
79 80 81 82 |
# File 'lib/a-tkcommons.rb', line 79 def stop_moving @moving_obj.bind_remove("B1-Motion") @moving_obj.bind_remove("ButtonPress-1") end |