SameBoy | Accurate GB/GBC emulator |
| download: https://git.y1.nz/archives/sameboy.tar.gz | |
| README | Files | Log | Refs | LICENSE |
Cocoa/GBDebuggerButton.m
1 #import "GBDebuggerButton.h"
2
3 @implementation GBDebuggerButton
4 {
5 NSTrackingArea *_trackingArea;
6 }
7 - (instancetype)initWithCoder:(NSCoder *)coder
8 {
9 self = [super initWithCoder:coder];
10 self.toolTip = self.title;
11 self.imagePosition = NSImageOnly; // Newer versions of AppKit refuse to respect the value from the nib file
12 return self;
13 }
14
15 - (void)mouseEntered:(NSEvent *)event
16 {
17 if (@available(macOS 10.10, *)) {
18 NSDictionary *attributes = @{
19 NSForegroundColorAttributeName: [NSColor colorWithWhite:1.0 alpha:0.5],
20 NSFontAttributeName: self.textField.font
21 };
22 self.textField.placeholderAttributedString =
23 [[NSAttributedString alloc] initWithString:self.alternateTitle attributes:attributes];
24 }
25 }
26
27 - (void)mouseExited:(NSEvent *)event
28 {
29 if (@available(macOS 10.10, *)) {
30 if ([self.textField.placeholderAttributedString.string isEqualToString:self.alternateTitle]) {
31 self.textField.placeholderAttributedString = nil;
32 }
33 }
34 }
35
36 - (void)updateTrackingAreas
37 {
38 [super updateTrackingAreas];
39 if (_trackingArea) {
40 [self removeTrackingArea:_trackingArea];
41 }
42
43 _trackingArea = [ [NSTrackingArea alloc] initWithRect:[self bounds]
44 options:NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways
45 owner:self
46 userInfo:nil];
47 [self addTrackingArea:_trackingArea];
48 }
49 @end
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.