Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > How define cursors in Cocoa?

How define cursors in Cocoa?
Thread Tools
Fresh-Faced Recruit
Join Date: Sep 2000
Location: Monopoli, Bary, ITALY
Status: Offline
Reply With Quote
Dec 12, 2002, 05:27 AM
 
I think that the definition of custom cursors using Cocoa is more convoluted then using Carbon.

In Carbon I can create a 'CURS' resource (with ResEdit) and design all cursors I need. Then with a single function call I can show any cursor I have created.

In Cocoa I need to save a tiff file for every cursor, then create a NSImage and then a NSCursor from the NSImage. I cannot save the cursor hotspot in the tiff file, so I must hardcode it in the code o save in some other file.

There is a simple software to create and manage cursors in OS X?

There is a simple procedure to create an NSImage from a 'CURS' resource?

Any suggestion?

Thanks, and sorry for my poor english.
     
Mac Elite
Join Date: Sep 2000
Location: Tempe, AZ
Status: Offline
Reply With Quote
Dec 12, 2002, 12:57 PM
 
If you prefer the Carbon way, why don't you use it? You can call Carbon API from within a Cocoa program, you know.
Geekspiff - generating spiffdiddlee software since before you began paying attention.
     
antofic  (op)
Fresh-Faced Recruit
Join Date: Sep 2000
Location: Monopoli, Bary, ITALY
Status: Offline
Reply With Quote
Dec 13, 2002, 08:36 AM
 
Yes, I can call Carbon SetCursor(), but how this call interact with some cocoa objects that call NSCursor methods internally?

And calling SetCursor() when exists a Cocoa object developed for this purpose is somewhat unpleasant...
     
Mac Elite
Join Date: Sep 2000
Location: Tempe, AZ
Status: Offline
Reply With Quote
Dec 13, 2002, 02:52 PM
 
Originally posted by antofic:
Yes, I can call Carbon SetCursor(), but how this call interact with some cocoa objects that call NSCursor methods internally?
It shouldn't be a problem. The Carbon & Cocoa APIs are both wrappers for the same private API, so the calls are basically equivalent.


And calling SetCursor() when exists a Cocoa object developed for this purpose is somewhat unpleasant...
No argument here. Personally, I don't have any problem with something like:
Code:
NSCursor *myCursor = [[[NSCursor alloc] initWithImage: [NSImage imageNamed: @"ExcitingCursor"] hotspot: NSZeroPoint] autorelease]; [myCursor set];
(untested code). Of course, you've got a hardcoded hotspot, but if you want to be fancy-dancy, you could read it out of a plist or something.
Geekspiff - generating spiffdiddlee software since before you began paying attention.
     
antofic  (op)
Fresh-Faced Recruit
Join Date: Sep 2000
Location: Monopoli, Bary, ITALY
Status: Offline
Reply With Quote
Dec 16, 2002, 05:18 AM
 
NSZeroPoint may be not the correct value...

And imagine to have 40-50 different cursors (I have a simil-CAD application with automatic snap to objects) scattered in 40-50 different files without saved hotspot offsets.

I need an application to design the cursor with his mask. Then I need to measure and save the hotspot offsets in somewhat other file for every cursor.
When I decide an update the cursor design I need to remember to update the hotspot offsets.

I simply think that this procedure is cumbersome...
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 01:57 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2