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 > Bug in NSCursor?

Bug in NSCursor?
Thread Tools
Mac Enthusiast
Join Date: Feb 2000
Location: Storrs,Connecticut, USA
Status: Offline
Reply With Quote
Mar 9, 2001, 03:56 PM
 
I have a game in which I want the cursor to change to an icon representing the current player. My icons are tiffs and they composite perfectly in any NSView. I have also composited the icon of my program and it renders perfectly. My program icon is a .icns file. I created my program icon and the other icons in Iconographer. I changed the other two icons into tiffs using the - (NSData *)TIFFRepresentation method in NSImage. Anyway all of these render perfectly in any of my views.

The problem that I have is that none of these icons will show up when I try to use them as my cursor icon. In my - (void)resetCursorRects method of my view I do remember to set the size to 16 by 16. I know that the problem isn't that I'm doing anything wrong loading the images or anything because I can use any other tiff or icns as my cursor without any trouble. The NSImage that I pass to the - (id)initWithImage NSImage *)newImage hotSpot NSPoint)aPoint method in NSCursor always returns YES to an - (BOOL)isValid message.

When I tell it to reference a file that doesn't exist for my image, the cursor simply doesn't change over my view. That's nothing special. When I give it anything other than the icons that I use with my program they change over my view and render perfectly. When I give it one of my icons the pointer disappears over my view. It still works; it's just that it is invisible. The icons work fine because they appear in the view. I use them there too. I have tried making copies of them and putting them on the desktop and referencing them that way. Same thing, I get blankness when I move over my view. Putting any other icons, like Clock.icns from the clok program and using that works fine.

It seems like NSCursor should be able to display any of these icons that I can use in any view. So.. is this a bug in NSCursor?

[This message has been edited by Dalgo (edited 03-09-2001).]
     
Dalgo  (op)
Mac Enthusiast
Join Date: Feb 2000
Location: Storrs,Connecticut, USA
Status: Offline
Reply With Quote
Mar 9, 2001, 09:04 PM
 
I think that I must be doing something wrong in implementing the resetCursorRects method in my subclass of NSView. It seems to randomly crash, even when I use a good image. The resulting backtrace is:

#0 0x720bb09c in objc_msgSend ()
#1 0x45c32eb0 in handleCursorRect ()
#2 0x45bd9ad8 in -[NSApplication sendEvent:] ()
#3 0x45b7ebd4 in -[NSApplication run] ()
#4 0x45bfbc28 in NSApplicationMain ()
#5 0x00002ef0 in main (argc=1, argv=0xbffffd58) at main.m:5
#6 0x00002e00 in _start ()
#7 0x00002c44 in start ()

I think that there is a bug with cursor rects but I don't know. Here is what I did to test one of my problems:

- (void)resetCursorRects
{
static int i =0;
[self discardCursorRects];
if(i == 2)
return;

NSBeep();
i++;'

[self addCursorRect:[self bounds] cursor:[NSCursor IBeamCursor]];
}

In this example I know when the method is called because it beeps. I setup a mousedown method so that it'd call this method. Here is what happens. The program starts. It beeps. I move my pointer into my view and it turns into an I-Beam. I click. It beeps. The pointer is still an Ibeam. I click one more time. This time:
Mar 09 21:58:49 TestProg[1249] Error in CGSRemoveTrackingArea (1001)
is dumped to output. I think it's because I called [self discardCursorRects]; when there were no rects. Anyway, the tracking rectangle does NOT go away. The cursor still becomes an I Beam when I move it into the view and an arrow when I move it out of the view. I can click all I want but I will still get the same error dumped to the console and it stays like I never got rid of the rectangle. However, If I resize the window then everything behaves the way that it should so... what am I doing wrong here or is the whole cursor system just really crappy in OS X? I mean it tends to crash and it doesn't update the cursor. What's up?
     
   
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 12:33 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