spiegel-keyman/mac/KeymanEngine4Mac/KeymanEngine4Mac/CoreWrapper/CoreKeyOutput.m
sgschantz 0288b72c84 fix(mac): made osk keys visible again
set clipsToBounds to true for osk and osk key views
This property began defaulting to false with the update to
macOS 14 sonoma causing the osk keys to become so large
that they obscured the entire osk view.
Also replaced and few more deprecated properties and functions.
2024-05-10 14:49:34 +07:00

61 lines
1.9 KiB
Objective-C

/**
* Keyman is copyright (C) SIL International. MIT License.
*
* CoreKeyOutput.m KeymanEngine4Mac
*
* Created by Shawn Schantz on 2023-10-31.
*
* A value object representing one or more actions returned by Keyman Core. A
* struct describing the actions is returned by Core when processing a key down
* event. These actions are then applied by the platform code to the text client
* to produce the desired output corresponding to the user's keystroke.
*
*/
#import "CoreKeyOutput.h"
@implementation CoreKeyOutput
-(instancetype)init:(NSUInteger)codePointsToDelete textToDelete:(NSString*)deletedText textToInsert:(NSString*)text optionsToPersist:(NSDictionary*)options alert:(BOOL)alert emitKeystroke:(BOOL)emit capsLockState:(CapsLockState)capsLock {
self = [super init];
if (self) {
self->_codePointsToDeleteBeforeInsert = codePointsToDelete;
self->_textToDelete = deletedText;
self->_textToInsert = text;
self->_optionsToPersist = options;
self->_alert = alert;
self->_emitKeystroke = emit;
self->_capsLockState = capsLock;
}
return self;
}
-(NSString *)description
{
NSData* data = [self.textToInsert dataUsingEncoding:NSUTF16LittleEndianStringEncoding];
return [[NSString alloc] initWithFormat: @"codePointsToDeleteBeforeInsert: %li, textToInsert: '%@', optionsToPersist: %@, alert: %d, emitKeystroke: %d, capsLockState: %d ", self.codePointsToDeleteBeforeInsert, data, self.optionsToPersist, self.alert, self.emitKeystroke, self.capsLockState];
}
-(BOOL)hasCodePointsToDelete {
return self.codePointsToDeleteBeforeInsert > 0;
}
-(BOOL)hasTextToInsert {
return self.textToInsert.length > 0;
}
-(BOOL)isDeleteOnlyScenario {
return (self.hasCodePointsToDelete && !self.hasTextToInsert);
}
-(BOOL)isInsertOnlyScenario {
return (!self.hasCodePointsToDelete && self.hasTextToInsert);
}
-(BOOL)isDeleteAndInsertScenario {
return (self.hasCodePointsToDelete && self.hasTextToInsert);
}
@end