Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
IMKCandidates provides features to show candidates and select one of them.
👀Show candidate window
By
show(IMKCandidatesLocationHint)
ofIMKCandidates
, candidate window will be shown.Window style is specified
panelType:
argument. Available options arekIMKSingleColumnScrollingCandidatePanel
,KIMKScrollingGridCandidatePanel
,KIMKSingleRowSteppingCandidatePanel
.kIMKSingleColumnScrollingCandidatePanel
:KIMKScrollingGridCandidatePanel
:KIMKSingleRowSteppingCandidatePanel
:📖Obtain candidates
Candidates are loaded when
update()
ofIMKCandidates
is called.Candidates are obtain by
candidates(_:)
ofIMKInputController
.⚡️ Candidate window
Candidate window can be manipulated through keyboard. E.g. move selection candidate by up/down key.
To achieve this, we should pass key event to candidate window.
👉Select candidate
When candidate's selection moved, IMKInputController method is called.
🍎 Apple API internal information
Some method of IMKCandidates doesn't work. In my reverse engineering, following method has empty implementation, so doesn't work.
func showAnnotation(NSAttributedString!)
func attachChild(IMKCandidates!, toCandidate: Int, type: IMKStyleType)
func showChild()
func showSublist([Any]!, subListDelegate: Any!)
func detachChild(Int)
func hideChild()
func candidateIdentifier(atLineNumber: Int)
func candidateStringIdentifier(Any!)
func lineNumberForCandidate(withIdentifier: Int)
func selectCandidate(Int)
func selectCandidate(withIdentifier: Int)
func clearSelection()
I reported this to Apple (rdar://34944196, rdar://34911503)
✏️ Design decision: EmojiAutomaton
I enhanced emoji im automaton to show emoji candidates.
Manipulation
I decided to use following manipulation.
:
into composing mode.InputController
's method is called, state changed into normal mode.Store NSEvent
To pass original
NSEvent
to candidate window, I extended user input to store its.See e88bb84 for detail.
Extended automaton
Add new user input type for non-text key(e.g. arrow key) and candidate select.
Add new state for candidate selection.
Add new transition.
🚧 WIP area
selectionKey
support