javascript - Electron: how to make the Edit menu automatically enable/disable based on context
问题描述
I'm working on a ReactJS Electron application which has an Edit
menu (as all apps do). To make it a well behaved app from a UI/UX-perspective, I want the Undo
/Redo
entries to automatically "go grey" when there is nothing in the buffer, and of course, become clickable when appropriate. Same for the editing entries (Cut
, Copy
, Paste
, and Select All
).
However, the clincher is that these entries should only become active when the user has brought into keyboard focus an input control, like in a form. If the focus is not on the input control (or all input controls are hidden), then the Edit
menu's entries should all be grayed out.
Presently, it seems that just plopping down an Edit
menu in the top bar does not automatically exhibit this sort of behavior.
Is there a built in way of doing this in Electron, or does one have to "hand do it" for each possible control that can appear? In other words, do I have to add an event to each control on each form?
解决方案
推荐阅读
- java - 更新用户地址 - Spring rest
- php - laravel auth routes 问题:登录和注册链接不起作用
- c - 静态库结构和包含
- ios - 如何让 WhatsApp for iOS 获取图像以在我的网站的 og 标签中设置预览?
- opc - 无法将大量数据写入kepware
- asp.net - 我可以将自动查询与 asp.net web api 一起使用吗?
- python-3.x - 使用 python 运行时,Flask 调试模式会给出“OSError: [Errno 8] Exec format error”
- node.js - “对象”类型不存在属性“成功”
- git - 如何同步/镜像 SourceForge 中的“文件”存储库和“git”存储库?
- android-studio - Gradle 分布不存在