Tool Cursor


#1

Hi All,
Since one hour I’m looking for a clear explanation about setting cursor in ruby API.
Inside my tool , I got this line:

            iConeDeLoutil = "RTE_64_yes.png"
	cursorDir = File.join(File.dirname(__FILE__), "..", "icon")
	cursor_path = File.join(cursorDir, iConeDeLoutil)
	if cursor_path
	  @cursor_id = UI.create_cursor(cursor_path, 0, 64 )
	end

But on my Mac book pro, Sketchup pro 2018, the icon appear on if the icon is 64x64px.
and its doen’t work on PC

if I switch on 32x32 , its work on pc but not on mac.

what is the best solution to manage cursor and cursor file ?

Thanks


#2

As long as you stick to PNG files I don’t think there should be any differences between platforms here.

Could the problem be that you try to set the hot spot to be on the 64th pixel even if there are just 32 pixels in the image?


#3

You need to only create the cursor ONCE and reference it with a constant …

CURSOR = UI.create_cursor( cursor_path, 0, hotspot )

Otherwise you are creating a new cursor object and ID each time the tool is activated.
This is poor resource management.


#4

ok thanks !