-
function QuickPhrase(text)
print("quickPhrase:" .. text)
if text == "test" then
print("匹配成功:" .. text)
return "测试"
end
end
local function registerModule()
fcitx.addQuickPhraseHandler("QuickPhrase")
end 在如上代码中使用快速输入功能输入 |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
得了.....看起来只有 |
Beta Was this translation helpful? Give feedback.
-
QuickPhrase 的 handler 的返回值必须符合特殊的要求,并不是返回字符串。你的返回结果不被认可。 首先返回结果是一个 table ,其次返回的每一项都需要是一个三元组 例如 其他还有一些特殊的类型,例如 fcitx.QuickPhraseAction.TypeToBuffer ,表示把候选继续输入到 quickphrase 的缓冲区中 fcitx.QuickPhraseAction.Break ,避免后续其他的 handler 处理 还有一些其他特殊的值的可以改变候选词按键类型之类,可以参考 https://github.com/fcitx/fcitx5-lua/blob/master/src/imeapi/imeapi.lua#L58 |
Beta Was this translation helpful? Give feedback.
QuickPhrase 的 handler 的返回值必须符合特殊的要求,并不是返回字符串。你的返回结果不被认可。
首先返回结果是一个 table ,其次返回的每一项都需要是一个三元组
{ 显示 , 提交, 类型 }
例如
{"A", "B", fcitx.QuickPhraseAction.Commit} 表示显示成 A ,提交成 B,类型是直接提交的候选词
其他还有一些特殊的类型,例如 fcitx.QuickPhraseAction.TypeToBuffer ,表示把候选继续输入到 quickphrase 的缓冲区中
fcitx.QuickPhraseAction.Break ,避免后续其他的 handler 处理
还有一些其他特殊的值的可以改变候选词按键类型之类,可以参考
https://github.com/fcitx/fcitx5-lua/blob/master/src/imeapi/imeapi.lua#L58