From 25bcd48e34c3cca91d0dc0f44a97f5edd6c0c6d7 Mon Sep 17 00:00:00 2001 From: Alexandre Lision <alexandre.lision@gmail.com> Date: Sun, 22 Mar 2015 22:49:12 -0400 Subject: [PATCH] call: fix callbar - press enter to start call Refs #67611 Change-Id: I721a6cdc93ec152958caa6234c738b285820e3c8 --- RingWindowController.h | 2 +- RingWindowController.mm | 24 ++++++++++++++++++++++-- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/RingWindowController.h b/RingWindowController.h index cfca2e70..77c93c4e 100644 --- a/RingWindowController.h +++ b/RingWindowController.h @@ -34,7 +34,7 @@ #import "HistoryViewController.h" #import "PreferencesViewController.h" -@interface RingWindowController : NSWindowController <NSToolbarDelegate>{ +@interface RingWindowController : NSWindowController <NSToolbarDelegate, NSTextFieldDelegate>{ IBOutlet NSView *currentView; } @property (nonatomic, assign) NSViewController *myCurrentViewController; diff --git a/RingWindowController.mm b/RingWindowController.mm index 64cf7fa2..e5e29673 100644 --- a/RingWindowController.mm +++ b/RingWindowController.mm @@ -168,8 +168,8 @@ static NSString* const kCallButtonIdentifer = @"CallButtonIdentifier"; callField = [[NSSearchField alloc] initWithFrame:NSMakeRect(0,0,400,21)]; [[callField cell] setSearchButtonCell:nil]; [callField setToolTip:@"Call"]; - //[callField setAlignment:NSCenterTextAlignment]; - + [callField setAlignment:NSCenterTextAlignment]; + [callField setDelegate:self]; [item setView:callField]; } @@ -194,7 +194,13 @@ static NSString* const kCallButtonIdentifer = @"CallButtonIdentifier"; } return item; +} +- (IBAction)placeCall:(id)sender +{ + Call* c = CallModel::instance()->dialingCall(); + c->setDialNumber(QString::fromNSString([callField stringValue])); + c << Call::Action::ACCEPT; } -(NSArray *)toolbarDefaultItemIdentifiers:(NSToolbar*)toolbar @@ -225,6 +231,20 @@ static NSString* const kCallButtonIdentifer = @"CallButtonIdentifier"; return nil; } +#pragma NSTextField Delegate + +- (BOOL)control:(NSControl *)control textView:(NSTextView *)fieldEditor doCommandBySelector:(SEL)commandSelector +{ + NSLog(@"Selector method is (%@)", NSStringFromSelector( commandSelector ) ); + if (commandSelector == @selector(insertNewline:)) { + if([[callField stringValue] isNotEqualTo:@""]) { + [self placeCall:nil]; + return YES; + } + } + + return NO; +} @end -- GitLab