diff --git a/mac/KeymanEngine4Mac/KeymanEngine4Mac.xcodeproj/project.pbxproj b/mac/KeymanEngine4Mac/KeymanEngine4Mac.xcodeproj/project.pbxproj index 2aa2eef6c4..2a75ceb378 100644 --- a/mac/KeymanEngine4Mac/KeymanEngine4Mac.xcodeproj/project.pbxproj +++ b/mac/KeymanEngine4Mac/KeymanEngine4Mac.xcodeproj/project.pbxproj @@ -49,6 +49,7 @@ E22A5A1120113DC100233965 /* KMEngineTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E22A5A1020113DC100233965 /* KMEngineTests.m */; }; E22A5A142011402E00233965 /* KeymanEngineTestsStaticHelperMethods.m in Sources */ = {isa = PBXBuildFile; fileRef = E22A5A132011402E00233965 /* KeymanEngineTestsStaticHelperMethods.m */; }; E2537D9A201641DA0069FEA6 /* TestMacEngine.kmx in Resources */ = {isa = PBXBuildFile; fileRef = E2537D99201641DA0069FEA6 /* TestMacEngine.kmx */; }; + E28C71E520EBBA2D002D959D /* KMkeyViewProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = E28C71E420EBBA2C002D959D /* KMkeyViewProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -108,6 +109,7 @@ E22A5A1220113F8100233965 /* KeymanEngineTestsStaticHelperMethods.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KeymanEngineTestsStaticHelperMethods.h; sourceTree = ""; }; E22A5A132011402E00233965 /* KeymanEngineTestsStaticHelperMethods.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KeymanEngineTestsStaticHelperMethods.m; sourceTree = ""; }; E2537D99201641DA0069FEA6 /* TestMacEngine.kmx */ = {isa = PBXFileReference; lastKnownFileType = file; path = TestMacEngine.kmx; sourceTree = ""; }; + E28C71E420EBBA2C002D959D /* KMkeyViewProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KMkeyViewProtocol.h; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -132,6 +134,7 @@ 981880641BC1EA5800A1FBA5 /* OnScreenKeyboard */ = { isa = PBXGroup; children = ( + E28C71E420EBBA2C002D959D /* KMkeyViewProtocol.h */, 981880651BC1EA5800A1FBA5 /* KeyLabel.h */, 981880661BC1EA5800A1FBA5 /* KeyLabel.m */, 981880671BC1EA5800A1FBA5 /* KeyLabelCell.h */, @@ -262,6 +265,7 @@ 984C2B041A79CA4F0023F89D /* NSArray+Action.h in Headers */, 980053351B37C9B50088DDDD /* NFont.h in Headers */, 9818807B1BC1EE9700A1FBA5 /* TimerTarget.h in Headers */, + E28C71E520EBBA2D002D959D /* KMkeyViewProtocol.h in Headers */, 984C2B191A79CB020023F89D /* WindowsVKCodes.h in Headers */, 984C2B0C1A79CA4F0023F89D /* KMCompGroup.h in Headers */, 984C2B101A79CA4F0023F89D /* KMCompStore.h in Headers */, diff --git a/mac/KeymanEngine4Mac/KeymanEngine4Mac/KME/OnScreenKeyboard/KMkeyViewProtocol.h b/mac/KeymanEngine4Mac/KeymanEngine4Mac/KME/OnScreenKeyboard/KMkeyViewProtocol.h new file mode 100644 index 0000000000..8a7e5b9ca6 --- /dev/null +++ b/mac/KeymanEngine4Mac/KeymanEngine4Mac/KME/OnScreenKeyboard/KMkeyViewProtocol.h @@ -0,0 +1,18 @@ +// +// KMkeyView.h +// KeymanEngine4Mac +// +// Created by tom on 7/3/18. +// Copyright © 2018 SIL International. All rights reserved. +// + +#ifndef KMkeyView_h +#define KMkeyView_h + +@protocol KMkeyView + +- (void)keyAction:(id)sender; + +@end + +#endif /* KMkeyView_h */ diff --git a/mac/KeymanEngine4Mac/KeymanEngine4Mac/KME/OnScreenKeyboard/KeyView.h b/mac/KeymanEngine4Mac/KeymanEngine4Mac/KME/OnScreenKeyboard/KeyView.h index d819de0c2e..daf7136540 100644 --- a/mac/KeymanEngine4Mac/KeymanEngine4Mac/KME/OnScreenKeyboard/KeyView.h +++ b/mac/KeymanEngine4Mac/KeymanEngine4Mac/KME/OnScreenKeyboard/KeyView.h @@ -8,12 +8,12 @@ #import #import "OSKKey.h" +#import "KMkeyViewProtocol.h" @interface KeyView : NSView @property (nonatomic, strong) OSKKey *key; -@property (nonatomic, assign) SEL action; -@property (nonatomic, strong) id target; // This has to be an OSKView * +@property (nonatomic, strong) id target; @property (nonatomic, strong) NSImage *bitmap; @property (nonatomic, assign) BOOL keyPressed; diff --git a/mac/KeymanEngine4Mac/KeymanEngine4Mac/KME/OnScreenKeyboard/KeyView.m b/mac/KeymanEngine4Mac/KeymanEngine4Mac/KME/OnScreenKeyboard/KeyView.m index 33bd5632cb..801e0581b0 100644 --- a/mac/KeymanEngine4Mac/KeymanEngine4Mac/KME/OnScreenKeyboard/KeyView.m +++ b/mac/KeymanEngine4Mac/KeymanEngine4Mac/KME/OnScreenKeyboard/KeyView.m @@ -232,16 +232,7 @@ const NSTimeInterval repeatInterval = 0.05f; } -(void)processKeyClick { - // This code was previously incorrectly implemented because the function call failed to pass "self" as the - // final parameter. This page describes the fix, as implemented here: - // https://stackoverflow.com/questions/27626617/how-to-solve-performselector-may-cause-leak-because-its-selector-is-unknown?noredirect=1&lq=1 - // This is almost certainly not the *best* way to implement this, but we're up against our release deadline, - // so it should be revisted soon to come up with a more readable and reliable approach, and maybe even a - // unit-testable one. - SEL selector = self.action; - IMP imp = [self.target methodForSelector:selector]; - void (*func)(id, SEL, id) = (void *)imp; - func(self.target, selector, (NSObject *)self); + [self.target keyAction:self]; } - (void)startTimerWithTimeInterval:(NSTimeInterval)interval { diff --git a/mac/KeymanEngine4Mac/KeymanEngine4Mac/KME/OnScreenKeyboard/OSKView.h b/mac/KeymanEngine4Mac/KeymanEngine4Mac/KME/OnScreenKeyboard/OSKView.h index 6773d09912..5338a822ab 100644 --- a/mac/KeymanEngine4Mac/KeymanEngine4Mac/KME/OnScreenKeyboard/OSKView.h +++ b/mac/KeymanEngine4Mac/KeymanEngine4Mac/KME/OnScreenKeyboard/OSKView.h @@ -6,10 +6,13 @@ // Copyright (c) 2017 SIL International. All rights reserved. // -#import -#import "KVKFile.h" +#ifndef OSKView_h +#define OSKView_h -@interface OSKView : NSView +#import "KVKFile.h" +#import "KMkeyViewProtocol.h" + +@interface OSKView : NSView @property (weak, nonatomic) KVKFile *kvk; @@ -24,3 +27,5 @@ - (void)resizeOSKLayout; @end + +#endif /* OSKView_h */ diff --git a/mac/KeymanEngine4Mac/KeymanEngine4Mac/KME/OnScreenKeyboard/OSKView.m b/mac/KeymanEngine4Mac/KeymanEngine4Mac/KME/OnScreenKeyboard/OSKView.m index 292b948aed..219a970fe1 100644 --- a/mac/KeymanEngine4Mac/KeymanEngine4Mac/KME/OnScreenKeyboard/OSKView.m +++ b/mac/KeymanEngine4Mac/KeymanEngine4Mac/KME/OnScreenKeyboard/OSKView.m @@ -95,7 +95,6 @@ NSRect rect = NSInsetRect(NSMakeRect(px, py, width, keyHeight), 2, 2); KeyView *keyView = [[KeyView alloc] initWithFrame:rect];; [keyView setKey:key]; - [keyView setAction:@selector(keyAction:)]; [keyView setTarget:self]; if (self.oskShiftState && (keyView.key.keyCode == MVK_LEFT_SHIFT || keyView.key.keyCode == MVK_RIGHT_SHIFT)) [keyView setKeyPressed:YES]; diff --git a/mac/KeymanEngine4Mac/KeymanEngine4Mac/KeymanEngine4Mac.h b/mac/KeymanEngine4Mac/KeymanEngine4Mac/KeymanEngine4Mac.h index 7b5aac16ca..2ce34326d4 100644 --- a/mac/KeymanEngine4Mac/KeymanEngine4Mac/KeymanEngine4Mac.h +++ b/mac/KeymanEngine4Mac/KeymanEngine4Mac/KeymanEngine4Mac.h @@ -26,6 +26,7 @@ FOUNDATION_EXPORT const unsigned char KeymanEngine4MacVersionString[]; #import #import #import +#import "KMkeyViewProtocol.h" #import "OSKView.h" #import "TimerTarget.h" diff --git a/mac/history.md b/mac/history.md index 8a9a588179..c2bd1a8713 100644 --- a/mac/history.md +++ b/mac/history.md @@ -1,5 +1,8 @@ # Keyman for macOS Version History +## 2018-07-?? 10.0.10? alpha +* Refactored target-action call from keyView + ## 2018-06-28 10.0.100 stable * 10.0 stable release