From 06cfcd612da7bed8b14df7f0f697a91340abd504 Mon Sep 17 00:00:00 2001 From: liusi Date: Mon, 14 Nov 2016 12:29:27 +0800 Subject: [PATCH 1/2] disable accelerator when menu item is disabled --- atom/browser/ui/accelerator_util.cc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/atom/browser/ui/accelerator_util.cc b/atom/browser/ui/accelerator_util.cc index eb89bf0c35f5..a7877a9c90ae 100644 --- a/atom/browser/ui/accelerator_util.cc +++ b/atom/browser/ui/accelerator_util.cc @@ -90,11 +90,12 @@ bool TriggerAcceleratorTableCommand(AcceleratorTable* table, const ui::Accelerator& accelerator) { if (ContainsKey(*table, accelerator)) { const accelerator_util::MenuItem& item = (*table)[accelerator]; - item.model->ActivatedAt(item.position); - return true; - } else { - return false; + if (item.model->IsEnabledAt(item.position)) { + item.model->ActivatedAt(item.position); + return true; + } } + return false; } } // namespace accelerator_util From 9e91f319c19bcc9b062e28bf07b7827984b0e340 Mon Sep 17 00:00:00 2001 From: liusi Date: Tue, 15 Nov 2016 13:19:34 +0800 Subject: [PATCH 2/2] fix linting error --- atom/browser/ui/accelerator_util.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/atom/browser/ui/accelerator_util.cc b/atom/browser/ui/accelerator_util.cc index a7877a9c90ae..b71ba1310b35 100644 --- a/atom/browser/ui/accelerator_util.cc +++ b/atom/browser/ui/accelerator_util.cc @@ -93,7 +93,7 @@ bool TriggerAcceleratorTableCommand(AcceleratorTable* table, if (item.model->IsEnabledAt(item.position)) { item.model->ActivatedAt(item.position); return true; - } + } } return false; }