Flutter Web上的键盘快捷键
我正在将键盘快捷键添加到Flutter Web应用程序中。
我在custom focusableActionDetector
中具有形式,其中快捷方式具有这样的形式:
SingleActivator(LogicalKeyboardKey.digit2)
操作是:
CustomActivateIntent: CallbackAction<CustomActivateIntent>(
onInvoke: (intent) { provider.value = "2"; },)
以相同的形式,我有几个数字textformfield
s。要允许编写字符“ 2”,我必须将这些文本字段放在一些新的focusableActionDetector
中,否则以前的检测器捕获命令,并且文本字段失去了“ 2”字符,这已经很完全怪异...此外,在任何文本字段中编写文本字段之后,Focus focus ftecter不再起作用。
我认为这可能与焦点系统有关,这对我来说还不清楚。 谁能帮助找到干净的解决方案?
I'm adding keyboard shortcuts to a Flutter web application.
I have a form within a custom FocusableActionDetector
where the shortcut has form like this:
SingleActivator(LogicalKeyboardKey.digit2)
and action is like:
CustomActivateIntent: CallbackAction<CustomActivateIntent>(
onInvoke: (intent) { provider.value = "2"; },)
In the same form I have a couple of numeric TextFormField
s. To permit writing the character "2" I have to put these text fields inside some new FocusableActionDetector
, otherwise the previous detector catches the command and the text field loses the "2" character, and this is already quite weird... Moreover, after writing in any of the text fields the form focus detector doesn't work anymore.
I think this could be related to the focus system, which is yet not that clear to me.
Can anyone help find a clean solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现了一个解决方法:
focusableActionDetector
现在先于if语句。代码看起来如下:texteditingInprogress
bool是提供商中的一个字段,由focusnode
s属于textcontroller
s。仍然这不是一个完美的解决方案,特别是我想理解为什么以前的方法不起作用。
I found a workaround: the
FocusableActionDetector
is now preceded by an if statement. The code looks like the following:The
textEditingInProgress
bool is a field in a provider and is controlled by theFocusNode
s belonging to theTextController
s.Still this is not a perfect solution, in particular I'd like to understand why the previous approach was not working.