Skip to content

Commit

Permalink
Use internal state key to change keyboard state
Browse files Browse the repository at this point in the history
  • Loading branch information
Inokinoki committed Dec 29, 2024
1 parent 8ac4f8a commit b7bf8bc
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
12 changes: 12 additions & 0 deletions uipanel/KeyAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,15 @@ class BackspaceKeyAction: SymbolKeyAction {
super.init(symbol: "BackSpace", label: "")
}
}

class InternalStateKeyAction: KeyAction {
init(label: String, action: @escaping (_ client: FcitxProtocol) -> Void) {
super.init(
key: label,
capsKey: label,
label: label,
capsLabel: label,
action: action
)
}
}
16 changes: 14 additions & 2 deletions uipanel/Keyboard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ class Keyboard: UIStackView {
["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"],
["q", "w", "e", "r", "t", "y", "u", "i", "o", "p"],
["a", "s", "d", "f", "g", "h", "j", "k", "l"],
["`", "z", "x", "c", "v", "b", "n", "m", ""],
[",", " ", "."],
["Shift", "`", "z", "x", "c", "v", "b", "n", "m", ""],
[",", "🌐", " ", "."],
]

init(_ client: FcitxProtocol) {
Expand Down Expand Up @@ -41,6 +41,18 @@ class Keyboard: UIStackView {
let button = Key(client, key, BackspaceKeyAction())
rowStackView.addArrangedSubview(button)
continue
} else if key == "🌐" {
let button = Key(client, key, InternalStateKeyAction(label: key, action: { client in
// TODO: switch keyboard
}))
rowStackView.addArrangedSubview(button)
continue
} else if key == "Shift" {
let button = Key(client, "", InternalStateKeyAction(label: key, action: { client in
// TODO: switch keyboard
}))
rowStackView.addArrangedSubview(button)
continue
}

let button = Key(client, key, AlphabetKeyAction(key: key))
Expand Down

0 comments on commit b7bf8bc

Please sign in to comment.