Reimplement click handling in scene.
[kaya.git] / lib / board / scene.rb
blob62065cecdb4e24326b182bb3a8efdf8ec76037dd
1 class Scene < Qt::GraphicsScene
2   def initialize
3     super
4     
5     @elements = []
6   end
8   def add_element(element)
9     @elements << element
10   end
11   
12   def mousePressEvent(e)
13     if e.button == Qt::LeftButton
14       @elements.each do |element|
15         if element.rect.contains(e.scene_pos)
16           element.on_click(e.scene_pos - element.rect.top_left)
17         end
18       end
19     end
20   end
21 end