InputMethodKit

RSS for tag

Develop input methods and manage communication with client applications, candidates windows, and input method modes using InputMethodKit.

InputMethodKit Documentation

Posts under InputMethodKit tag

10 Posts
Sort by:
Post not yet marked as solved
1 Replies
152 Views
I modified an InputMethodKit example (fairly recent one from github, compiled fine and worked as expected on my machine as it was) to create a window with a WKWebView and the window doesn't load. I know that loadView is getting called, but the window never appears after calling showWindow on the window controller and there is a mysterious error in the console: bootstrap_check_in(): (os/kern) unknown error code (44c) From googling this it seems App Sandbox related, but I think I have everything set up correctly (App Sandbox on with outgoing connections allowed) Totally stumped, any help or ideas would be appreciated Here's the relevant code: View controller import Foundation import WebKit import AppKit class InputWindowViewController: NSViewController, WKUIDelegate { var webView: WKWebView! override func loadView() { NSLog("LoadView") webView = WKWebView() self.view = webView webView.uiDelegate = self webView.needsDisplay = true } override func viewDidLoad() { super.viewDidLoad() webView.load(URLRequest(url: URL(string:"https://www.apple.com")!)) } } Window controller import AppKit import Foundation import WebKit class InputWindowController: NSWindowController { var controller: InputWindowViewController? override init(window: NSWindow?) { controller = nil super.init(window: window) } override func loadWindow() { self.window = NSWindow(contentViewController: controller!) } required init?(coder: NSCoder) { controller = nil super.init(coder: coder) } } AppDelegate import Cocoa import InputMethodKit import WebKit // Necessary to launch this app class NSManualApplication: NSApplication { private let appDelegate = AppDelegate() override init() { super.init() self.delegate = appDelegate } required init?(coder: NSCoder) { // No need for implementation fatalError("init(coder:) has not been implemented") } } @main class AppDelegate: NSResponder, NSApplicationDelegate { var server = IMKServer() var candidates = IMKCandidates() var inputWindowController = InputWindowController() func applicationDidFinishLaunching(_ notification: Notification) { // Insert code here to initialize your application server = IMKServer(name: Bundle.main.infoDictionary?["InputMethodConnectionName"] as? String, bundleIdentifier: Bundle.main.bundleIdentifier) inputWindowController = InputWindowController() inputWindowController.controller = InputWindowViewController() inputWindowController.loadWindow() inputWindowController.showWindow(self) candidates = IMKCandidates(server: server, panelType: kIMKSingleRowSteppingCandidatePanel, styleType: kIMKMain) NSLog("tried connection") } func applicationWillTerminate(_ notification: Notification) { // Insert code here to tear down your application } } This code is probably awful in a lot of other ways I don't realize, but I wanted to get a webview window up before I put a bunch of time into this thing XCode 13.4 MacoOS 12.7.4
Posted Last updated
.
Post not yet marked as solved
0 Replies
203 Views
-1 I am trying to write a MacOS app which switch input methods by previously assigned shortcut(command+space in here). Switching input methods preoperly works so that the language icon at the status bar(top right) immediately changes as I put the shortcut. The problem I got in here is that the actual input method does not change. For example, if I run my app when the selected input method is Korean, then although the status bar is showing the selected input method is Japanese after command+space, what I can only type is Korean characters. However, after I change focus to another text app(e.g. from sublime text to xcode), only then the selected input method is reflected well. I am using MacOS Monterey 12.6 and Xcode 13.1. My project contains two source files. The code in the file AppDelegate.swift is as follows: import Cocoa @NSApplicationMain class AppDelegate: NSObject, NSApplicationDelegate { var switcher = Switcher() } And the code in the file Switcher.swift is as follows: import Cocoa import MASShortcut class Switcher{ var lang: Int = 0 var kr: TISInputSource? var jp: TISInputSource? var en: TISInputSource? init(){ let inputSourceNSArray = TISCreateInputSourceList(nil, false).takeRetainedValue() as NSArray let inputSourceList = inputSourceNSArray as! [TISInputSource] for inputSource in inputSourceList { if inputSource.id == "com.apple.inputmethod.Korean.2SetKorean" { self.kr = inputSource } if inputSource.id == "com.apple.inputmethod.Kotoeri.RomajiTyping.Japanese" { self.jp = inputSource } if inputSource.id == "com.apple.keylayout.ABC" { self.en = inputSource } } self.register() } func switchLang(){ self.lang = (self.lang + 1) % 3 switch lang { case 0: TISSelectInputSource(self.kr) case 1: TISSelectInputSource(self.jp) case 2: TISSelectInputSource(self.en) default: print("error") } } func register() { let langShortcut = MASShortcut(keyCode: kVK_Space, modifierFlags: [.command]) MASShortcutMonitor.shared()?.register(langShortcut, withAction: { self.switchLang() }) } } I wrote these codes by referring KAWA, but KAWA does not make this issue. I have analyzed all codes of KAWA several times, I couldn't find out why the same problem does not occur in KAWA. I am quite new to Swift, and I have no idea to approach. Could you help me....? Thank you.
Posted Last updated
.
Post not yet marked as solved
0 Replies
238 Views
I am using Mac's own Pinyin input method, candidate word size 18 is too small, 24 is too big, the middle of the 20 and 22 options should be more appropriate, but currently does not support selection, I hope to increase these two options, maybe this is most people's favorite size
Posted
by dufu1991.
Last updated
.
Post not yet marked as solved
0 Replies
433 Views
What's the right way to implement key equivalent matching that handles non-Roman/Latin layouts? E.g. pressing Cmd+Option+C in a Greek layout produces an NSEvent with chars="ç" unmodchars="ψ", neither of which is going to match a key equivalent of Cmd+Option+C by simile comparison, yet performKeyEquivalent on a button with that exact key equivalent returns YES and activates the button. How would someone replicate that? [NSEvent charactersByApplyingModifiers:] also reports "ç", and so does UCKeyTranslate. Yet the Keyboard Viewer shows a modifier layer with "c", not the "ç" that the event reports:
Posted
by torarnv.
Last updated
.
Post not yet marked as solved
3 Replies
421 Views
Hello everyone, I am currently working on a project that requires me to programmatically manage keyboard layouts on both iOS and macOS devices. I'm looking for a comprehensive list of KeyboardLayout ID values for all the native keyboard layouts available in both iOS and macOS. While I can extract some of this information from the /System/Library/Keyboard Layouts/ directory on macOS, I cannot extract all without adding every keyboard layout active, having a complete and pre-compiled list would be immensely helpful. Does anyone here have such a list or know where I might find one? Any guidance on this matter would be greatly appreciated. Thank you in advance for your assistance! JJ
Posted
by qcx5.
Last updated
.
Post not yet marked as solved
1 Replies
1.2k Views
iOS16 lists supporting pinyin for Shanghainese and Sichuanese pharase. Aswell as now supporting a phonetic input method for Cantonese. Does anyone know how this function works, I have had no success in using Shanghai romanization or Sichuanese pinyin: Keyboard still produces only Standard Written Chinese (Mandarin) output. Further enhabling this under -Settings/General/Keyboard/Pinyin/Regional Dialect shows "Support for typing words with the selected dialect will download when connected to Wi-Fi" despite having been so. Any one know anything about this?
Posted
by qcx5.
Last updated
.
Post not yet marked as solved
1 Replies
642 Views
I have been researching and enduring the most unbelievable attack you have ever heard of. You won't believe me. AT&T doesn't. Apple doesn't. They have not bothered to even take a look. I have multiple screen videos and screenshots that prove that when my phone was stolen, damaged, then returned, it was infected with a very resilient virus of some sort, so that it has been cloned and is duplicated on a MAC. Now the WiFi network I use is likely the jumping off point, but I am not familiar with this level of invasion. I have restored the phone but I have not deleted the E-Sim. And I always restored from a backup. Well once. I did not and still no change. I am not a neophyte, and while I have limited knowledge of the apple code, swift or Xcode or whatever, I do have some coding knowledge from other platforms. One thing I do know though is my iPhone. I bought the first one in 2007 and watched the keynote announcing the App Store on the first iPhone. I know when it is operating as it should. For instance, whenever I reset my google password which is often, or I just look through the google account at devices, this iPhone 14 {Plus running iOS 17 is always listed as a MAC OS X from another region. Sometimes I can see this phone on there as well but it is never the (device I am using). Also, I have screen videos of very strange errors, like certain options will be shut off. Like right now I cannot turn on voice assist. During the damage when it was stolen, the Face ID was damaged. Just now it suddenly got brighter and it does that often almost as often as the volume suddenly going up. My contacts are constantly deleted and that is not because of switching accounts. As this has been occurring four over 4 months now, I have tirelessly investigated every explanation for the errors. I know it is a mac connected to the same WiFi because occasionally the font will change in size and small part of text will be highlighted and it is much smaller than the display of the phone. Everytime I login to Apple ID the password has been changed and this is with 2FA on. Also I just checked yesterday to see, on the AT&T website, and my number in just one day has (5Text messages listed that I did not get. My roommates seem to know things about me I haven't told them. At&T sent me a bill for a different number without a phone connected to it. I use an ESim. I have endless more details and screenshots and I cannot seem to get a response from apple, but my belongings have been stolen, my identity stolen, and my sanity also taken away. You begin to question reality, but just going over my body of evidence is enough to show I have something going on. I want to report this to someone but I would like to maybe get some info on how I could be sure, what is happening? MY Crash reports show interesting stuff. I am actually going to check and make sure the imei numbers in those reports match the device. But please help . This is like super high tech invisible terrorizing spyware and it will be worse for the next person. I mean when I unlock my phone it is never opened to the app I closed it on. NEVER. Email johnmichaelpowers@yahoo.com
Posted Last updated
.
Post not yet marked as solved
2 Replies
1.7k Views
Crash - 1: Fatal Exception: NSRangeException 0 CoreFoundation 0x9e38 __exceptionPreprocess 1 libobjc.A.dylib 0x178d8 objc_exception_throw 2 CoreFoundation 0x1af078 -[__NSCFString characterAtIndex:].cold.1 3 CoreFoundation 0x1a44c -[CFPrefsPlistSource synchronize] 4 UIKitCore 0x1075f68 -[UIPredictionViewController predictionView:didSelectCandidate:] 5 TextInputUI 0x2461c -[TUIPredictionView _didRecognizeTapGesture:] 6 UIKitCore 0xbe180 -[UIGestureRecognizerTarget _sendActionWithGestureRecognizer:] 7 UIKitCore 0x42c050 _UIGestureRecognizerSendTargetActions 8 UIKitCore 0x1a5a18 _UIGestureRecognizerSendActions 9 UIKitCore 0x86274 -[UIGestureRecognizer _updateGestureForActiveEvents] 10 UIKitCore 0x132348 _UIGestureEnvironmentUpdate 11 UIKitCore 0x9ba418 -[UIGestureEnvironment _deliverEvent:toGestureRecognizers:usingBlock:] 12 UIKitCore 0xf6df4 -[UIGestureEnvironment _updateForEvent:window:] 13 UIKitCore 0xfb760 -[UIWindow sendEvent:] 14 UIKitCore 0xfaa20 -[UIApplication sendEvent:] 15 UIKitCore 0xfa0d8 __dispatchPreprocessedEventFromEventQueue 16 UIKitCore 0x141e00 __processEventQueue 17 UIKitCore 0x44a4f0 __eventFetcherSourceCallback 18 CoreFoundation 0xd5f24 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION 19 CoreFoundation 0xe22fc __CFRunLoopDoSource0 20 CoreFoundation 0x661c0 __CFRunLoopDoSources0 21 CoreFoundation 0x7bb7c __CFRunLoopRun 22 CoreFoundation 0x80eb0 CFRunLoopRunSpecific 23 GraphicsServices 0x1368 GSEventRunModal 24 UIKitCore 0x3a1668 -[UIApplication _run] 25 UIKitCore 0x3a12cc UIApplicationMain ============================================================ Crash - 2: Crashed: com.apple.root.background-qos 0 libobjc.A.dylib 0x1c20 objc_msgSend + 32 1 UIKitCore 0xb0e0d8 __37-[UIDictationConnection cancelSpeech]_block_invoke + 152 2 libdispatch.dylib 0x24b4 _dispatch_call_block_and_release + 32 3 libdispatch.dylib 0x3fdc _dispatch_client_callout + 20 4 libdispatch.dylib 0x15b8c _dispatch_root_queue_drain + 684 5 libdispatch.dylib 0x16284 _dispatch_worker_thread2 + 164 6 libsystem_pthread.dylib 0xdbc _pthread_wqthread + 228 7 libsystem_pthread.dylib 0xb98 start_wqthread + 8 ============================================================ I encountered the two keyboard-related crashes in iOS 16.x, but I cannot reproduce them. Can anyone tell me what is going on and how to fix them? Please let me know.
Posted
by lowser.
Last updated
.
Post not yet marked as solved
0 Replies
737 Views
Hi all, I'm working on an iOS app that takes a user's input via touch and returns audio and haptic feedback relative to how hard the user touches the screen (i.e., the harder the user touches the screen, the louder the volume and stronger the haptic response will be). The problem is that the tracking of pressure sensitivity only seems to be available on iOS devices with 3D Touch functionality, which Apple discontinued in 2019-2020 in favor of the much simpler Haptic Touch functionality, which does not appear to offer dynamic tracking of touch inputs. How does this affect my users? Well, those who have an older iPhone between 6s and 11 (excluding SE and XR) will have access to a fully functional immersive environment that provides dynamic audio and haptic responses based on the pressure of their touch inputs - exactly as intended. Unfortunately, the majority of my users who use an iPhone 12 or above will be left with a static environment that provides the same audio and haptic response regardless of the pressure of their touch inputs. Ironically, users with old iPhones will have full access to my app's functionality, while users with new iPhones will be excluded from the experience that I wish to provide. As a developer who is passionate about providing dynamic and immersive experiences to more than a subset of his users, Apple's dropping of 3D Touch for Haptic Touch feels like a massive downgrade in terms of functionality and performance. Is there any way to bypass the limitations of the new Haptic Touch iPhones so that I can record touch pressure sensitivity and provide new iPhone users with the same dynamic experience that old iPhone users enjoy?
Posted
by DogeFlyer.
Last updated
.
Post not yet marked as solved
0 Replies
927 Views
I write macOS menu app with TextField by SwiftUI on Japanese Input mode. On some conditions, the TextFiled lost focus, no key input, no mouse click. User cannot do anything. Setup MacOS Ventura 13.3.1 (a) Install Japanese Romaji Input source by System Preferences -> Keyboard Set input mode as "Romaji" Build test source code On Xcode 14.3, create new macOS app project "FocusTest" with SwiftUI, Swift. Replace FocusTestApp.swift with attached code. Build on Xcode Steps Set input mode as "Romaji" Run FocusTestApp Click T square icon on top menu Small windows with globe appear Click Desktop background area Click T square icon on top menu Click PIN T with PIN textField View appear That textField lost focus, click inside of textField Key or click is not accepted. With US keyboard mode, key input become possible on Step 10. But Focused blue square is missing. Code of FocusTestApp.swift import SwiftUI @main struct focusTestApp: App { var body: some Scene { MenuBarExtra("Test", systemImage: "t.square") { MainView() }.menuBarExtraStyle(.window) } } struct MainView: View { @State private var showingPIN: Bool = false var body: some View { VStack { Image(systemName: "globe") .imageScale(.large) .foregroundColor(.accentColor) Button("PIN") { print("clicked") showingPIN = true } } .padding() .sheet(isPresented: $showingPIN) { PinView() } } } struct PinView: View { @Environment(\.presentationMode) var presentationMode @State private var pin: String = "" @FocusState private var pinIsFocused: Bool var body: some View { VStack { Image(systemName: "t.square") .resizable() .aspectRatio(contentMode: .fit) .frame(width: 64.0, height: 64.0) .foregroundColor(.accentColor) Text("Enter PIN code") HStack { TextField("", text: $pin) .font(Font.system(size: 28, design: .default)) .frame(width:4*28.0, height:28.0) .focusable() .focused($pinIsFocused) } .onAppear(){ pinIsFocused = true } } .padding() } }
Posted
by Himadeus.
Last updated
.