Skip to content

IDialogService中的open方法,按回车键会关闭弹框,快捷键事件怎么禁用或者重写? #2338

Answered by erha19
lovelytan asked this question in Q&A
Discussion options

You must be logged in to vote

@naduohua 这部分快捷键的注册逻辑在 https://github.com/opensumi/core/blob/f3fd01381d6ee854102d491b14957e9e634941a3/packages/overlay/src/browser/dialog.contribution.ts#L37~L41

你可以通过注册一个 KeybindingContribution 去卸载这个快捷键的注册:

registerKeybindings(bindings: KeybindingRegistry) {
    bindings.unregisterKeybinding({
      command: DIALOG_COMMANDS.ENSURE.id,
      keybinding: 'enter',
      when: `${DialogViewVisibleContext.raw}`,
    });
  }

@Autowired(KeybindingRegistry)
protected keybindingRegistry: KeybindingRegistry;

this.keybindingRegistry.unregisterKeybinding({
      command: DIALOG_COMMANDS.ENSURE.id,
      keybinding: 'enter',
      when: `${DialogViewVisibleContext.raw}`,
});

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by lovelytan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants