Alexandre Lision | 6200531 | 2016-01-28 15:55:16 -0500 | [diff] [blame] | 1 | /* |
Sébastien Blin | 029ffa8 | 2019-01-02 17:43:48 -0500 | [diff] [blame] | 2 | * Copyright (C) 2016-2019 Savoir-faire Linux Inc. |
Alexandre Lision | 6200531 | 2016-01-28 15:55:16 -0500 | [diff] [blame] | 3 | * Author: Alexandre Lision <alexandre.lision@savoirfairelinux.com> |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 3 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | */ |
| 19 | |
| 20 | #import "DialpadWC.h" |
| 21 | |
Alexandre Lision | 6200531 | 2016-01-28 15:55:16 -0500 | [diff] [blame] | 22 | @interface DialpadWC () |
| 23 | |
| 24 | @property (unsafe_unretained) IBOutlet NSTextField* composerField; |
| 25 | |
| 26 | @end |
| 27 | |
| 28 | @implementation DialpadWC |
| 29 | @synthesize composerField; |
| 30 | |
| 31 | - (void)windowDidLoad { |
| 32 | [super windowDidLoad]; |
Alexandre Lision | 6200531 | 2016-01-28 15:55:16 -0500 | [diff] [blame] | 33 | } |
| 34 | |
| 35 | - (IBAction)dtmfPressed:(id)sender |
| 36 | { |
| 37 | [self sendDTMF:[sender title]]; |
| 38 | } |
| 39 | |
| 40 | - (void) keyDown:(NSEvent *)theEvent |
| 41 | { |
| 42 | NSString* characters = [theEvent characters]; |
| 43 | if ([characters length] == 1) { |
| 44 | NSString* filter = @"0123456789*#"; |
| 45 | if ([filter containsString:characters]) { |
| 46 | [self sendDTMF:characters]; |
| 47 | } |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | - (void) sendDTMF:(NSString*) dtmf |
| 52 | { |
Alexandre Lision | 6200531 | 2016-01-28 15:55:16 -0500 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | ///Accessibility |
| 56 | - (void)insertTab:(id)sender |
| 57 | { |
| 58 | if ([[self window] firstResponder] == self) { |
| 59 | [[self window] selectNextKeyView:self]; |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | - (void)insertBacktab:(id)sender |
| 64 | { |
| 65 | if ([[self window] firstResponder] == self) { |
| 66 | [[self window] selectPreviousKeyView:self]; |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | - (void) windowWillClose:(NSNotification *)notification |
| 71 | { |
| 72 | [composerField setStringValue:@""]; |
| 73 | [composerField setNeedsDisplay:YES]; |
| 74 | } |
| 75 | |
| 76 | @end |