Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8981043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:14:06+00:00 2026-06-15T20:14:06+00:00

I am working on a Mac application with Xcode (using cocos2d), trying to configure

  • 0

I am working on a Mac application with Xcode (using cocos2d), trying to configure the cursor, and the “set” method does not seem to have any effect in some cases…

I already had a hard time to set my cursor at the launch of the application (NSTimer to set it after the application was really launched), and now I just want it to display another image when the user clicks; I use NSNotification for that, my cursor class receives the notification, then it is supposed to set the new image, then… nothing.

Here is some code which may help:

-(void) click  
{  
    CCLOG(@"Click");  
    NSString *path = [[NSBundle mainBundle] pathForResource:@"point_pressed" ofType:@"png"];  
    NSImage *cursorImage = [[[NSImage alloc] initByReferencingFile:path] autorelease];  
    NSCursor *cursor = [[NSCursor alloc] initWithImage:cursorImage hotSpot:[[NSCursor currentCursor] hotSpot]];  
    [cursor set];  
}  

In the initialization:

    [NSTimer scheduledTimerWithTimeInterval:0.1f target:self selector:@selector(updateCursor:) userInfo:nil repeats:NO];  

And the method:

-(void) updateCursor:(id)sender  
{  
    CCLOG(@"Update cursor");  
    [[self.cursorsDict objectForKey:@"point"] set];  
}  

The “updateCursor” method is also called when the application becomes active, and then it works fine, the correct cursor is displayed.
I have tried many things, pop and push methods, “setOnMouseEnter” (although I don’t use rect yet), but no result…
Has anyone a clue about this?

Edit:

Stranger, I wrote the appWake method:

-(void) appWake
{
    int i = rand()%3;
    if(i==0)
        [[self.cursorsDict objectForKey:@"point"] set];
    else if(i==1)
        [[self.cursorsDict objectForKey:@"point_pressed"] set];
    else if(i==2)
        [[self.cursorsDict objectForKey:@"open"] set];
    self.state = ECursorState_Point;
    [NSTimer scheduledTimerWithTimeInterval:0.5f target:self selector:@selector(appWake) userInfo:nil repeats:NO];
}

Which is called by a notification:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appWake) name:EVENT_APPLICATION_DID_BECOME_ACTIVE object:nil];

Set in the appDelegate by:

-(void) applicationDidBecomeActive:(NSNotification *)notification
{
    [[NSNotificationCenter defaultCenter] postNotificationName:EVENT_APPLICATION_DID_BECOME_ACTIVE object:nil];
}

And when it’s called by this notification, it works fine, the cursor changes randomly; but if I remove the notification in applicationDidBecomeActive and call it somewhere else in my code, then it does not do anything (although I checked that it is called)…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T20:14:08+00:00Added an answer on June 15, 2026 at 8:14 pm

    I know it has been awhile. But I had a similar problem.

    For some reason [cursor set] doesn’t work when being called from the application events.

    Here is how I did it:

    - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
    {
        [self performSelector:@selector(doChangeCursor) withObject:nil afterDelay:1];
    }
    
    - (void) doChangeCursor
    {
        NSString *file = [[NSBundle mainBundle] pathForResource:@"statusBarImage" ofType:@"tiff"];
        NSImage *image = [[NSImage alloc] initWithContentsOfFile:file];
        NSCursor *cursor = [[NSCursor alloc] initWithImage:image hotSpot:NSMakePoint(0, 0)];
        [cursor set];    
    }
    

    I hope this is able to help someone.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Core Data based mac application that is working perfectly well until
we have successfully created a decent phonegap application working on android and iphone. (using
I had a working Mac application until I updated to XCode 4.4 and Mountain
I have installed xCode 4.0.2 on my mac mini, every thing is working fine,
I'm trying to deploy an application on the mac app store. I'm working through
I'm working on an menulet-based application for the Mac that requires me to have
I am trying to update facebook from my Mac application i am working on.
I have an OSX application written in Objective-C/Cocoa using xcode. The application is quite
I'm trying to create a simple data entry application for the Mac (not iPhone).
I am creating an application for Mac using Xcode 4.2, and I wanted to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.