Setting custom cursor for a Tool
-
I'm trying to set a custom cursor for a Tool. From the manual on Tool.onSetCursor http://code.google.com/apis/sketchup/docs/ourdoc/tool.html#onSetCursor
@unknownuser said:
The onSetCursor method is called by SketchUp when the tool wants to set the cursor. If your tool needs to have more than one cursor, then you will need to implement this method, but if it only has one you can set the cursor in the activate method.
Since I only have one icon for the Tool I tried setting in the
activatemethod:UI.set_cursor(@cursor_id)The tool is define in the initialize method;
cursor_path = Sketchup.find_support_file("rotascale.png", "Plugins/TT_RotaScale") if cursor_path @cursor_id = UI.create_cursor(cursor_path, 14, 13) else @cursor_id = 0 endThe problem is that the cursor briefly flickers when I activate it, then it reverts back to the default arrow.
When I try to add this:
def onSetCursor(view) UI.set_cursor(@cursor_id) endI get error messages flooding the console:
wrong number of arguments(0 for 1)for theonSetCursorevent. (It also reports incorrect line number for the error.) -
Dont know it it helps in your case but heres a snippet from f2f.rb:
@@cursor = 0 def initialize @@cursor = UI;;create_cursor((File.join(File.dirname(__FILE__), "f2f_cursor.gif")),1,30) if @@cursor == 0 end def onSetCursor UI;;set_cursor(@@cursor) end -
Hm... it turns out that onSetCursor doesn't actually return the view as an argument. Works now. Thanks man!

Advertisement