事件通知
当键盘元素需要根据某些状态动态变化时,就可以使用「事件通知」功能。
比如:
- 模仿系统键盘回车键在某些场景下是蓝色,某些是正常系统键颜色。
- 跟踪并显示当前 RIME 某个 option 的值,比如 ascii_mode 的值,以完成 RIME 的中英文输入切换。
通知的设置需要绑定在按键样式上,具体来说,就是在按键样式的 notification 配置中进行设置。
按键也包含工具栏上的按键。
示例:
qButton: backgroundStyle: alphabeticBackgroundStyle foregroundStyle: - qButtonForegroundStyle - qButtonUpForegroundStyle ... notification: - keyboardActionNotification目前通知有以下几种类型:
- RIME 类型通知:监听 RIME 引擎通知事件。
- 键盘动作类型通知:监听键盘发出的某一种 KeyboardAction。
- 回车键类型通知:监听系统回车键的类型。
- RIME 预编辑文本通知类型:监听 RIME 预编辑文本的变化。
RIME 类型通知
Section titled “RIME 类型通知”RIME 类型通知用于监听 RIME 输入法的通知事件。
notificationType: rimeRIME 类型通知也有自己的分类,通过 rimeNotificationType 设置:
optionChanged: 监听 RIME option 变更schemaChanged: 监听 rime 输入方案变更
RIME Option 变更通知
Section titled “RIME Option 变更通知”RIME Option 变更通知用于监听 RIME 输入法的 option 变更事件。
notificationType: rimerimeNotificationType: optionChanged
rimeOptionName: ascii_mode
rimeOptionValue: true只有当通知中的内容与 rimeOptionName 和 rimeOptionValue 设置的内容匹配时,才会触发样式变化。
RIME schema 变更通知
Section titled “RIME schema 变更通知”RIME schema 变更通知用于监听 RIME 引擎的输入方案变更事件。
notificationType: rimerimeNotificationType: schemaChanged键盘动作类型通知
Section titled “键盘动作类型通知”键盘动作类型通知用于监听键盘发出的某一种 KeyboardAction。
notificationType: keyboardAction
notificationKeyboardAction: { character: 'a' }回车键类型通知
Section titled “回车键类型通知”回车键类型通知用于监听系统回车键的类型。
notificationType: returnKeyType
returnKeyType: [1, 4, 7]RIME 预编辑文本通知类型
Section titled “RIME 预编辑文本通知类型”RIME 预编辑文本通知类型用于监听 RIME 预编辑文本的变化。
notificationType: preeditChanged根据通知调整按键样式及动作
Section titled “根据通知调整按键样式及动作”在通知设置中,可以通过 backgroundStyle,foregroundStyle,action 参数改变按键的样式及触发动作。
blueReturnKeyTypeNotification: notificationType: returnKeyType returnKeyType: [1, 4, 7]
backgroundStyle: blueSystemButtonBackgroundStyle foregroundStyle: enterButtonWhiteForegroundStyle
action: enter