I am using a simple observer for tools. Code below.
I noticed that when I move object method invoked 3 times.
1 time when I grab the object
2 times when I leave an object.
Unfortunately, the 2 times when I leave the object I have tool_state == 0 so I have no idea how I can recognize that 'one time
My task is to run a function of everything when the user ‘leaves’ the grabbed object. Would be nice to avoid static/classes/global variables to do this. Any thoughts?
At first, I thought that I added observer twice, but the grabbing object invoke only once (tool_state == 1)
class MyToolsObserver < Sketchup::ToolsObserver
def onActiveToolChanged(tools, tool_name, tool_id)
puts "onActiveToolChanged: #{tool_name}"
end
def onToolStateChanged(tools, tool_name, tool_id, tool_state)
puts "onToolStateChanged: #{tool_id} - #{tool_name}:#{tool_state}"
end
end