mirror of
https://github.com/keymanapp/keyman.git
synced 2026-09-22 07:37:40 +00:00
[Mac] [WIP] - Refactoring of target-action call from keyView
This commit is contained in:
parent
1c6d5256ac
commit
28147b631c
8 changed files with 37 additions and 16 deletions
|
|
@ -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 = "<group>"; };
|
||||
E22A5A132011402E00233965 /* KeymanEngineTestsStaticHelperMethods.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KeymanEngineTestsStaticHelperMethods.m; sourceTree = "<group>"; };
|
||||
E2537D99201641DA0069FEA6 /* TestMacEngine.kmx */ = {isa = PBXFileReference; lastKnownFileType = file; path = TestMacEngine.kmx; sourceTree = "<group>"; };
|
||||
E28C71E420EBBA2C002D959D /* KMkeyViewProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KMkeyViewProtocol.h; sourceTree = "<group>"; };
|
||||
/* 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 */,
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
@ -8,12 +8,12 @@
|
|||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#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 <KMkeyView> target;
|
||||
@property (nonatomic, strong) NSImage *bitmap;
|
||||
@property (nonatomic, assign) BOOL keyPressed;
|
||||
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -6,10 +6,13 @@
|
|||
// Copyright (c) 2017 SIL International. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#import "KVKFile.h"
|
||||
#ifndef OSKView_h
|
||||
#define OSKView_h
|
||||
|
||||
@interface OSKView : NSView
|
||||
#import "KVKFile.h"
|
||||
#import "KMkeyViewProtocol.h"
|
||||
|
||||
@interface OSKView : NSView <KMkeyView>
|
||||
|
||||
@property (weak, nonatomic) KVKFile *kvk;
|
||||
|
||||
|
|
@ -24,3 +27,5 @@
|
|||
- (void)resizeOSKLayout;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* OSKView_h */
|
||||
|
|
|
|||
|
|
@ -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];
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ FOUNDATION_EXPORT const unsigned char KeymanEngine4MacVersionString[];
|
|||
#import <KeymanEngine4Mac/NFont.h>
|
||||
#import <KeymanEngine4Mac/NSArray+Action.h>
|
||||
#import <KeymanEngine4Mac/NSString+XString.h>
|
||||
#import "KMkeyViewProtocol.h"
|
||||
#import "OSKView.h"
|
||||
#import "TimerTarget.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue