diff --git a/Cocoa/GBView.m b/Cocoa/GBView.m index b0657c1..86adccc 100644 --- a/Cocoa/GBView.m +++ b/Cocoa/GBView.m @@ -1,4 +1,5 @@ #import +#import #import "GBView.h" #import "GBButtons.h" #import "NSString+StringForKey.h" @@ -152,6 +153,27 @@ static GBShader *shader = nil; glViewport(0, 0, self.bounds.size.width * scale, self.bounds.size.height * scale); } +- (BOOL)becomeFirstResponder +{ + /* Non-Roman keyboard layouts breaks user input. */ + TSMDocumentID document = TSMGetActiveDocument(); + + CFArrayRef inpu_sources = TISCreateASCIICapableInputSourceList(); + TSMSetDocumentProperty(document, kTSMDocumentEnabledInputSourcesPropertyTag, + sizeof(CFArrayRef), &inpu_sources); + CFRelease(inpu_sources); + + return [super becomeFirstResponder]; +} + +- (BOOL)resignFirstResponder +{ + TSMDocumentID document = TSMGetActiveDocument(); + TSMRemoveDocumentProperty(document, kTSMDocumentEnabledInputSourcesPropertyTag); + + return [super resignFirstResponder]; +} + - (BOOL)acceptsFirstResponder { return YES;