-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBRNumberField.m
60 lines (49 loc) · 1.08 KB
/
BRNumberField.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//
// BRNumberField.m
// BRNumberFormatter
//
// Created by Yang on 3/3/16.
// Copyright © 2016 sgyang. All rights reserved.
//
#import "BRNumberField.h"
#import "BRNumberFormatter.h"
@implementation BRNumberField
@dynamic max;
- (instancetype)initWithFrame:(NSRect)frameRect
{
self = [super initWithFrame:frameRect];
if (self) {
[self setup];
}
return self;
}
- (instancetype)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
if (self) {
[self setup];
}
return self;
}
- (void)setup
{
[super setFormatter:[[BRNumberFormatter alloc] init]];
[(NSTextFieldCell*)self.cell setAllowedInputSourceLocales:@[NSAllRomanInputSourcesLocaleIdentifier]];
}
- (void)setMax:(NSUInteger)max
{
[(BRNumberFormatter *)self.formatter setMax:max];
}
- (NSUInteger)max
{
return [(BRNumberFormatter *)self.formatter max];
}
- (void)setFormatter:(__kindof NSFormatter *)formatter
{
NSLog(@"Can't change formatter");
}
- (void)drawRect:(NSRect)dirtyRect {
[super drawRect:dirtyRect];
// Drawing code here.
}
@end