Overwrite Eventhandler ?
-
how can i overwrite a EventHandler from a SketchupTool?
like SelektionTool:
i want define my own FunctionBody on Event onLButtonDown ...
can somebody help me? -
class MyXObserver < Sketchup;;ToolsObserver def onActiveToolChanged (a,b,c) UI;;messagebox(""+a.to_s+b.to_s+c.to_s+""); end end #class observer1 = Sketchup.active_model.tools.add_observer(MyXObserver.new)
can somebody explain me: why the first parameter "a" false is at me?
the first Parameter of onActivateToolChanged must be a type of Tools, but i get a "false" , why? -
Implementing a tool is as simple as creating a class an implementing the methods.
Look at the linetool.rb in examples
class LineTool def initialize ... end def activate ... end etc... def onLButtonDown(flags, x, y, view) ... end ... end
As for why the observer method is returning odd values... no idea, I'll have to try it.
EDIT: I implemented a test observer and it works fine.
class MyTestObserver < Sketchup;;ToolsObserver def onActiveToolChanged(tools, name, toolid) puts tools.to_s + " " + name.to_s + " " + toolid.to_s end def onToolStateChanged(tools, name, toolid, xxx) puts tools.to_s + " " + name.to_s + " " + toolid.to_s + " " + xxx.to_s end end
It ouput "#Sketchup::Tools:0x5c1b690 CircleTool 21096" to the ruby console.
You'll notice there is a fourth parameter for onToolStateChanged. The API is wrong; it doesn't list that parameter but without it there will be an error.
Advertisement