• Login
sketchucation logo sketchucation
  • Login
⚠️ Libfredo 15.4b | Minor release with bugfixes and improvements Update

Setting custom cursor for a Tool

Scheduled Pinned Locked Moved Developers' Forum
3 Posts 2 Posters 504 Views 2 Watching
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    thomthom
    last edited by 20 May 2009, 19:05

    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 activate method:

    
    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
    end
    
    

    The 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)
    end
    
    

    I get error messages flooding the console: wrong number of arguments(0 for 1) for the onSetCursor event. (It also reports incorrect line number for the error.)

    Thomas Thomassen — SketchUp Monkey & Coding addict
    List of my plugins and link to the CookieWare fund

    1 Reply Last reply Reply Quote 0
    • P Offline
      Pixero
      last edited by 20 May 2009, 19:18

      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
      
      1 Reply Last reply Reply Quote 0
      • T Offline
        thomthom
        last edited by 20 May 2009, 19:29

        Hm... it turns out that onSetCursor doesn't actually return the view as an argument. Works now. Thanks man! 👍

        Thomas Thomassen — SketchUp Monkey & Coding addict
        List of my plugins and link to the CookieWare fund

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        1 / 1
        • First post
          1/3
          Last post
        Buy SketchPlus
        Buy SUbD
        Buy WrapR
        Buy eBook
        Buy Modelur
        Buy Vertex Tools
        Buy SketchCuisine
        Buy FormFonts

        Advertisement