nscursor

How to change the size of the system cursor in a macosx cocoa app programmatically using swift or objective-c?

帅比萌擦擦* 提交于 2019-12-10 10:01:44
问题 I've tried to set it's global size using this code: -(void)setOption { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSDictionary *olddict = [defaults persistentDomainForName:@"com.apple.universalaccess"]; NSMutableDictionary *newdict = [olddict mutableCopy]; [newdict setObject:@4.0 forKey:@"mouseDriverCursorSize"]; [defaults setPersistentDomain:newdict forName:@"com.apple.universalaccess"]; [defaults synchronize]; NSLog(@"Cursor size set to %@", newdict); } And I can see

Native OSX Lion resize cursor for custom NSWindow or NSView

吃可爱长大的小学妹 提交于 2019-12-09 16:30:43
问题 If we use NSTrackingArea for some specified region then we can implement such method to change the default cursor: -(void)cursorUpdate:(NSEvent *)theEvent { [[NSCursor resizeLeftCursor] set]; } I implementing custom resize for NSWindow , which uses NSBorderlessWindowMask . And want to use native Lion's two arrows cursors. But such type of cursors not exist in NSCursor API. Can I get such native cursors somehow from code? Or maybe I must redraw them by hand (not a good idea)? 回答1: WebKit

NSCursor: “set” method has no effect

半城伤御伤魂 提交于 2019-12-06 08:39:57
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 = [

How to force the cursor to be an “arrowCursor” when it hovers a NSButton that is inside a NSTextView?

北慕城南 提交于 2019-12-05 20:32:18
Okay, here is the problem: I have a NSTextView and I add my custom NSButton using: [_textView addSubview:button]; Then, inside my NSButton subclass, I have (along with the NSTrackingArea stuff): - (void)mouseEntered:(NSEvent *)event{ [[NSCursor arrowCursor] set]; } - (void)mouseExited:(NSEvent *)theEvent{ [[NSCursor arrowCursor] set]; } - (void)mouseDown:(NSEvent *)theEvent{ [[NSCursor arrowCursor] set]; } - (void)mouseUp:(NSEvent *)theEvent{ [[NSCursor arrowCursor] set]; } But when I hover it, the cursor remains the same IBeamCursor (because it's a NSTextView ). Only when I press the button,

How to change the size of the system cursor in a macosx cocoa app programmatically using swift or objective-c?

╄→гoц情女王★ 提交于 2019-12-05 20:16:06
I've tried to set it's global size using this code: -(void)setOption { NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSDictionary *olddict = [defaults persistentDomainForName:@"com.apple.universalaccess"]; NSMutableDictionary *newdict = [olddict mutableCopy]; [newdict setObject:@4.0 forKey:@"mouseDriverCursorSize"]; [defaults setPersistentDomain:newdict forName:@"com.apple.universalaccess"]; [defaults synchronize]; NSLog(@"Cursor size set to %@", newdict); } And I can see in the NSLog that it changed it but I don't know how to restart/reset the system cursor in order for

NSCursor: Using high-resolution cursors with cursor zoom (or retina)

不问归期 提交于 2019-12-04 10:07:58
问题 In OSX the user can zoom the mouse cursor using the accessibility system preferences. Since Lion (I think) OSX stores the cursors as PDFs and is able to resize them smoothly. I want the same functionality for my app but using PDFs as the NSImage used for my NSCursor just scales up the rendered bitmap when a cursor zoom level larger than 1.0 is set. How do I: Use vector artwork for my cursors and have them scale correctly like the system cursors do? Detect the current cursor zoom level. Get

Cocoa predefined resize mouse cursor?

半腔热情 提交于 2019-12-04 08:31:10
Is the resize mouse cursor used by Preview (e.g. when resizing shapes) a system cursor? It's not available directly as a method in NSCursor but then it doesn't look like there's a private resource for the cursor in the Preview app's bundle either.. Are there more system cursors other than the methods defined by the NSCursor class..? I think you are particularly interested in these class methods (Preview.app dissasembly). +[NSCursor resizeAngle45Cursor]; which calls +[NSCursor _windowResizeNorthEastSouthWestCursor]; +[NSCursor resizeAngle135Cursor]; which calls +[NSCursor

NSCursor: Using high-resolution cursors with cursor zoom (or retina)

微笑、不失礼 提交于 2019-12-03 05:55:46
In OSX the user can zoom the mouse cursor using the accessibility system preferences. Since Lion (I think) OSX stores the cursors as PDFs and is able to resize them smoothly. I want the same functionality for my app but using PDFs as the NSImage used for my NSCursor just scales up the rendered bitmap when a cursor zoom level larger than 1.0 is set. How do I: Use vector artwork for my cursors and have them scale correctly like the system cursors do? Detect the current cursor zoom level. Get notified when the cursor zoom level changes? Also, when using a HiDPI mode for my screen and revert the

Can't change the mouse cursor of a NSTextField

烂漫一生 提交于 2019-11-29 05:08:19
I'm trying to change the mouse cursor of a NSTextField in a window sheet, loaded from a NIB. Following the documentation, I have subclassed NSTextField and implemented resetCursorRects . - (void) resetCursorRects { [self addCursorRect:[self bounds] cursor:[NSCursor pointingHandCursor]]; } This is never called. Not even after adding the following in the NSWindowViewController : - (void) windowDidLoad { [self.window invalidateCursorRectsForView:self.linkTextField]; } I also tried with a tracking area by adding the following in the NSTextField subclass: - (void) awakeFromNib { NSTrackingArea*

Can't change the mouse cursor of a NSTextField

我只是一个虾纸丫 提交于 2019-11-27 18:54:48
问题 I'm trying to change the mouse cursor of a NSTextField in a window sheet, loaded from a NIB. Following the documentation, I have subclassed NSTextField and implemented resetCursorRects. - (void) resetCursorRects { [self addCursorRect:[self bounds] cursor:[NSCursor pointingHandCursor]]; } This is never called. Not even after adding the following in the NSWindowViewController : - (void) windowDidLoad { [self.window invalidateCursorRectsForView:self.linkTextField]; } I also tried with a tracking