nstrackingarea

Swift NSTextField text disappears

孤街醉人 提交于 2020-02-05 02:33:05
问题 This questions MIGHT exist on a 6 year old post in objective-c. I haven't found a recent answer or question that works, or one that is written in Swift. I'm using storyboards and I have subclassed NSTextField . For some reason when I click into the field, the placeholder shows and when I enter text and click out, the text disappears. The text is actually there, because when I click back in, the entered text persists. It seems that it's some type of rendering issue that a layer is covering up

mouseExited isn't called when mouse leaves trackingArea while scrolling

人走茶凉 提交于 2019-12-17 17:31:15
问题 Why mouseExited/mouseEntered isn't called when mouse exits from NStrackingArea by scrolling or doing animation? I create code like this: Mouse entered and exited: -(void)mouseEntered:(NSEvent *)theEvent { NSLog(@"Mouse entered"); } -(void)mouseExited:(NSEvent *)theEvent { NSLog(@"Mouse exited"); } Tracking area: -(void)updateTrackingAreas { if(trackingArea != nil) { [self removeTrackingArea:trackingArea]; [trackingArea release]; } int opts = (NSTrackingMouseEnteredAndExited |

Set the cursor to a pointing hand over a text view

核能气质少年 提交于 2019-12-10 17:20:54
问题 Is there a way to set the cursor to a pointing hand over a text view without subclassing NSTextView? I read a lot about NSTrackingAreas, tested a lot of examples, set different tracking options and implemented different methods, but the cursor still remains an I-Beam. I have read that it is an AppKit automatic feature, so how can I prevent this? Thank you! 回答1: I had to subclass. After a couple of hours to test a lot of methods and options, this finally worked : @implementation ATTextView -

Custom NSStatusItem and NSView not reliably receiving NSTrackingEvents

只愿长相守 提交于 2019-12-10 10:42:07
问题 I have a Status-Bar item only app that Iam trying to get to show a panel on mouseOver. I have the custom status item (and associated view) hooked up and working, but the tracking rect is only receiving events on every dozen or so launches. This leads me to believe there is a race condition happening somewhere, but I can't find it. In my custom status bar item view: - (id)initWithStatusItem:(NSStatusItem *)statusItem { CGFloat itemWidth = [statusItem length]; CGFloat itemHeight = [[NSStatusBar

Custom NSStatusItem and NSView not reliably receiving NSTrackingEvents

孤街醉人 提交于 2019-12-06 05:33:00
I have a Status-Bar item only app that Iam trying to get to show a panel on mouseOver. I have the custom status item (and associated view) hooked up and working, but the tracking rect is only receiving events on every dozen or so launches. This leads me to believe there is a race condition happening somewhere, but I can't find it. In my custom status bar item view: - (id)initWithStatusItem:(NSStatusItem *)statusItem { CGFloat itemWidth = [statusItem length]; CGFloat itemHeight = [[NSStatusBar systemStatusBar] thickness]; NSRect itemRect = NSMakeRect(0.0, 0.0, itemWidth, itemHeight); NSLog(@

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,

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*

mouseExited isn't called when mouse leaves trackingArea while scrolling

邮差的信 提交于 2019-11-28 03:41:33
Why mouseExited/mouseEntered isn't called when mouse exits from NStrackingArea by scrolling or doing animation? I create code like this: Mouse entered and exited: -(void)mouseEntered:(NSEvent *)theEvent { NSLog(@"Mouse entered"); } -(void)mouseExited:(NSEvent *)theEvent { NSLog(@"Mouse exited"); } Tracking area: -(void)updateTrackingAreas { if(trackingArea != nil) { [self removeTrackingArea:trackingArea]; [trackingArea release]; } int opts = (NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways); trackingArea = [ [NSTrackingArea alloc] initWithRect:[self bounds] options:opts owner:self

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