| 1 | /* Copyright (C) 2008-2009 Peter Speck |
|---|
| 2 | * |
|---|
| 3 | * This program is free software: you can redistribute it and/or modify |
|---|
| 4 | * it under the terms of the GNU General Public License as published by |
|---|
| 5 | * the Free Software Foundation, either version 3 of the License, or |
|---|
| 6 | * (at your option) any later version. |
|---|
| 7 | * |
|---|
| 8 | * This program is distributed in the hope that it will be useful, |
|---|
| 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 11 | * GNU General Public License for more details. |
|---|
| 12 | * |
|---|
| 13 | * You should have received a copy of the GNU General Public License |
|---|
| 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
|---|
| 15 | */ |
|---|
| 16 | |
|---|
| 17 | #import "ClickActionTextField.h" |
|---|
| 18 | #import "GlimmerBlockerPane.h" |
|---|
| 19 | |
|---|
| 20 | @implementation ClickActionTextField |
|---|
| 21 | |
|---|
| 22 | - (void)dealloc |
|---|
| 23 | { |
|---|
| 24 | [super dealloc]; |
|---|
| 25 | } |
|---|
| 26 | |
|---|
| 27 | - (void)setTarget:(id)target selector:(SEL)selector |
|---|
| 28 | { |
|---|
| 29 | _target = target; |
|---|
| 30 | _selector = selector; |
|---|
| 31 | } |
|---|
| 32 | |
|---|
| 33 | - (void)mouseDown:(NSEvent*)theEvent |
|---|
| 34 | { |
|---|
| 35 | // http://theocacao.com/document.page/264 |
|---|
| 36 | NSMethodSignature* sig = [[_target class] instanceMethodSignatureForSelector:_selector]; |
|---|
| 37 | NSInvocation* invo = [NSInvocation invocationWithMethodSignature:sig]; |
|---|
| 38 | [invo setTarget:_target]; |
|---|
| 39 | [invo setSelector:_selector]; |
|---|
| 40 | [invo setArgument:self atIndex:2]; |
|---|
| 41 | [invo invoke]; |
|---|
| 42 | } |
|---|
| 43 | |
|---|
| 44 | - (void)resetCursorRects |
|---|
| 45 | { |
|---|
| 46 | [self addCursorRect:[self bounds] cursor:[NSCursor pointingHandCursor]]; |
|---|
| 47 | } |
|---|
| 48 | |
|---|
| 49 | @end |
|---|
| 50 | |
|---|
| 51 | //------------------------------------------------------------------------ |
|---|
| 52 | |
|---|
| 53 | @implementation OpenWebsiteOnClickTextField |
|---|
| 54 | |
|---|
| 55 | - (void)mouseDown:(NSEvent *)theEvent |
|---|
| 56 | { |
|---|
| 57 | [GlimmerBlockerPrefsPane openWebsiteInBrowser]; |
|---|
| 58 | } |
|---|
| 59 | |
|---|
| 60 | - (void)resetCursorRects |
|---|
| 61 | { |
|---|
| 62 | [self addCursorRect:[self bounds] cursor:[NSCursor pointingHandCursor]]; |
|---|
| 63 | } |
|---|
| 64 | |
|---|
| 65 | @end |
|---|
| 66 | |
|---|
| 67 | //------------------------------------------------------------------------ |
|---|
| 68 | |
|---|
| 69 | @implementation OpenWebsiteOnClickImage |
|---|
| 70 | |
|---|
| 71 | - (void)mouseDown:(NSEvent *)theEvent |
|---|
| 72 | { |
|---|
| 73 | [GlimmerBlockerPrefsPane openWebsiteInBrowser]; |
|---|
| 74 | } |
|---|
| 75 | |
|---|
| 76 | - (void)resetCursorRects |
|---|
| 77 | { |
|---|
| 78 | [self addCursorRect:[self bounds] cursor:[NSCursor pointingHandCursor]]; |
|---|
| 79 | } |
|---|
| 80 | |
|---|
| 81 | @end |
|---|