Files

49 lines
1.8 KiB
C
Raw Permalink Normal View History

2025-10-28 10:18:10 +08:00
//
// KBKey.h
// CustomKeyboard
//
// 简单的键位数据模型,用于描述键盘上的一个键。
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
typedef NS_ENUM(NSInteger, KBKeyType) {
KBKeyTypeCharacter = 0, // 普通字符输出
KBKeyTypeBackspace, // 删除
KBKeyTypeShift, // 大小写切换
KBKeyTypeModeChange, // 模式切换(如 123/ABC
KBKeyTypeSpace, // 空格
KBKeyTypeReturn, // 回车/发送
KBKeyTypeGlobe, // 系统地球键
2025-10-28 20:03:43 +08:00
KBKeyTypeCustom, // 自定义功能占位
KBKeyTypeSymbolsToggle // 数字面板内的“#+=/123”切换
2025-10-28 10:18:10 +08:00
};
2025-11-18 20:53:47 +08:00
/// 字母键的大小写变体标记(非字母键使用 KBKeyCaseVariantNone
typedef NS_ENUM(NSInteger, KBKeyCaseVariant) {
KBKeyCaseVariantNone = 0,
KBKeyCaseVariantLower = 1,
KBKeyCaseVariantUpper = 2,
};
2025-10-28 10:18:10 +08:00
@interface KBKey : NSObject
@property (nonatomic, assign) KBKeyType type;
@property (nonatomic, copy) NSString *title; // 显示标题
@property (nonatomic, copy) NSString *output; // 字符键插入的文本
2025-11-18 20:53:47 +08:00
/// 逻辑按键标识,用于皮肤映射(如 @"letter_q" @"space" @"backspace"
@property (nonatomic, copy, nullable) NSString *identifier;
/// 字母键的大小写变体(便于皮肤为大小写准备不同图)
@property (nonatomic, assign) KBKeyCaseVariant caseVariant;
2025-10-28 10:18:10 +08:00
+ (instancetype)keyWithTitle:(NSString *)title output:(NSString *)output;
+ (instancetype)keyWithTitle:(NSString *)title type:(KBKeyType)type;
2025-11-18 20:53:47 +08:00
/// 通用构造方法:用于指定 identifier便于皮肤做精细控制
+ (instancetype)keyWithIdentifier:(nullable NSString *)identifier
title:(NSString *)title
output:(NSString *)output
type:(KBKeyType)type;
2025-10-28 10:18:10 +08:00
@end