This commit is contained in:
2025-10-28 14:30:03 +08:00
parent 1deca2ae5b
commit 377e88b6db
12 changed files with 688 additions and 42 deletions

View File

@@ -28,27 +28,12 @@ static CGFloat KEYBOARDHEIGHT = 256;
- (void)viewDidLoad {
[super viewDidLoad];
//
// // Perform custom UI setup here
// self.nextKeyboardButton = [UIButton buttonWithType:UIButtonTypeSystem];
//
// [self.nextKeyboardButton setTitle:NSLocalizedString(@"Next Keyboard", @"Title for 'Next Keyboard' button") forState:UIControlStateNormal];
// [self.nextKeyboardButton sizeToFit];
// self.nextKeyboardButton.translatesAutoresizingMaskIntoConstraints = NO;
//
// [self.nextKeyboardButton addTarget:self action:@selector(handleInputModeListFromView:withEvent:) forControlEvents:UIControlEventAllTouchEvents];
//
// [self.view addSubview:self.nextKeyboardButton];
//
// [self.nextKeyboardButton.leftAnchor constraintEqualToAnchor:self.view.leftAnchor].active = YES;
// [self.nextKeyboardButton.bottomAnchor constraintEqualToAnchor:self.view.bottomAnchor].active = YES;
[self setupUI];
}
- (void)setupUI {
// self.view.translatesAutoresizingMaskIntoConstraints = NO;
//
[self.view.heightAnchor constraintEqualToConstant:KEYBOARDHEIGHT].active = YES;
@@ -74,38 +59,15 @@ static CGFloat KEYBOARDHEIGHT = 256;
}
- (void)viewWillLayoutSubviews
{
self.nextKeyboardButton.hidden = !self.needsInputModeSwitchKey;
[super viewWillLayoutSubviews];
}
- (void)textWillChange:(id<UITextInput>)textInput {
//
}
- (void)textDidChange:(id<UITextInput>)textInput {
//
UIColor *textColor = nil;
if (self.textDocumentProxy.keyboardAppearance == UIKeyboardAppearanceDark) {
textColor = [UIColor whiteColor];
} else {
textColor = [UIColor blackColor];
}
[self.nextKeyboardButton setTitleColor:textColor forState:UIControlStateNormal];
}
#pragma mark - KBToolBarDelegate
- (void)toolBar:(KBToolBar *)toolBar didTapActionAtIndex:(NSInteger)index {
// [A1]..[A4]
NSString *placeholder = [NSString stringWithFormat:@"[A%ld]", (long)index+1];
[self.textDocumentProxy insertText:placeholder];
// NSString *placeholder = [NSString stringWithFormat:@"[A%ld]", (long)index+1];
}
- (void)toolBarDidTapSettings:(KBToolBar *)toolBar {
// openURL 宿
//
[self.textDocumentProxy insertText:@"[settings]"];
}