[Question] 编辑器右上角按钮菜单,如何控制按钮的enable disable #2144
Answered
by
erha19
767746649zyy
asked this question in
Q&A
-
描述你的问题(Describe you question here) |
Beta Was this translation helpful? Give feedback.
Answered by
erha19
Dec 30, 2022
Replies: 1 comment 1 reply
-
@767746649zyy 如果想动态控制 EditorTitle 区域的菜单是否可用状态,可用通过注册时追加 @Autowired(IContextKeyService)
private readonly contextKeyService: IContextKeyService;
const key = contextKeyService.createKey<boolean>('customAction.isRunning', false);
// 更新
key.set(true); 注册伪代码: menuRegistry.registerMenuItem(MenuId.DebugBreakpointsContext, {
...
enableWhen: `... && custom.isRunning`
}); |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
erha19
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@767746649zyy 如果想动态控制 EditorTitle 区域的菜单是否可用状态,可用通过注册时追加
enabledWhen
属性,与在Command
中使用isEnabled
区别的是,when
类型的参数会动态响应条件变化,但需要你自主注册条件,如,你可以直接通过使用IContextKeyService
去注册自定义 ContextKey,伪代码如下:注册伪代码: