parent
7ce338e420
commit
b57b342352
6 changed files with 6 additions and 73 deletions
|
@ -64,7 +64,6 @@ bool StringToAccelerator(const std::string& shortcut,
|
||||||
}
|
}
|
||||||
|
|
||||||
*accelerator = ui::Accelerator(key, modifiers);
|
*accelerator = ui::Accelerator(key, modifiers);
|
||||||
SetPlatformAccelerator(accelerator);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,9 +23,6 @@ typedef std::map<ui::Accelerator, MenuItem> AcceleratorTable;
|
||||||
bool StringToAccelerator(const std::string& description,
|
bool StringToAccelerator(const std::string& description,
|
||||||
ui::Accelerator* accelerator);
|
ui::Accelerator* accelerator);
|
||||||
|
|
||||||
// Set platform accelerator for the Accelerator.
|
|
||||||
void SetPlatformAccelerator(ui::Accelerator* accelerator);
|
|
||||||
|
|
||||||
// Generate a table that contains memu model's accelerators and command ids.
|
// Generate a table that contains memu model's accelerators and command ids.
|
||||||
void GenerateAcceleratorTable(AcceleratorTable* table,
|
void GenerateAcceleratorTable(AcceleratorTable* table,
|
||||||
atom::AtomMenuModel* model);
|
atom::AtomMenuModel* model);
|
||||||
|
|
|
@ -1,46 +0,0 @@
|
||||||
// Copyright (c) 2013 GitHub, Inc.
|
|
||||||
// Use of this source code is governed by the MIT license that can be
|
|
||||||
// found in the LICENSE file.
|
|
||||||
|
|
||||||
#include "atom/browser/ui/accelerator_util.h"
|
|
||||||
|
|
||||||
#include "ui/base/accelerators/accelerator.h"
|
|
||||||
#import "ui/base/accelerators/platform_accelerator_cocoa.h"
|
|
||||||
#import "ui/events/keycodes/keyboard_code_conversion_mac.h"
|
|
||||||
|
|
||||||
namespace accelerator_util {
|
|
||||||
|
|
||||||
void SetPlatformAccelerator(ui::Accelerator* accelerator) {
|
|
||||||
unichar character;
|
|
||||||
unichar characterIgnoringModifiers;
|
|
||||||
|
|
||||||
NSUInteger modifiers = (accelerator->IsCtrlDown() ? NSControlKeyMask : 0) |
|
|
||||||
(accelerator->IsCmdDown() ? NSCommandKeyMask : 0) |
|
|
||||||
(accelerator->IsAltDown() ? NSAlternateKeyMask : 0) |
|
|
||||||
(accelerator->IsShiftDown() ? NSShiftKeyMask : 0);
|
|
||||||
|
|
||||||
ui::MacKeyCodeForWindowsKeyCode(accelerator->key_code(), modifiers,
|
|
||||||
&character, &characterIgnoringModifiers);
|
|
||||||
|
|
||||||
if (character != characterIgnoringModifiers) {
|
|
||||||
if (isdigit(characterIgnoringModifiers)) {
|
|
||||||
// The character is a number so lets not mutate it with the modifiers
|
|
||||||
character = characterIgnoringModifiers;
|
|
||||||
} else {
|
|
||||||
modifiers ^= NSShiftKeyMask;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (character == NSDeleteFunctionKey) {
|
|
||||||
character = NSDeleteCharacter;
|
|
||||||
}
|
|
||||||
|
|
||||||
NSString* characters =
|
|
||||||
[[[NSString alloc] initWithCharacters:&character length:1] autorelease];
|
|
||||||
|
|
||||||
std::unique_ptr<ui::PlatformAccelerator> platform_accelerator(
|
|
||||||
new ui::PlatformAcceleratorCocoa(characters, modifiers));
|
|
||||||
accelerator->set_platform_accelerator(std::move(platform_accelerator));
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace accelerator_util
|
|
|
@ -1,13 +0,0 @@
|
||||||
// Copyright (c) 2013 GitHub, Inc.
|
|
||||||
// Use of this source code is governed by the MIT license that can be
|
|
||||||
// found in the LICENSE file.
|
|
||||||
|
|
||||||
#include "atom/browser/ui/accelerator_util.h"
|
|
||||||
|
|
||||||
#include "ui/base/accelerators/accelerator.h"
|
|
||||||
|
|
||||||
namespace accelerator_util {
|
|
||||||
|
|
||||||
void SetPlatformAccelerator(ui::Accelerator* accelerator) {}
|
|
||||||
|
|
||||||
} // namespace accelerator_util
|
|
|
@ -239,14 +239,12 @@ static base::scoped_nsobject<NSMenu> recentDocumentsMenuSwap_;
|
||||||
ui::Accelerator accelerator;
|
ui::Accelerator accelerator;
|
||||||
if (model->GetAcceleratorAtWithParams(index, useDefaultAccelerator_,
|
if (model->GetAcceleratorAtWithParams(index, useDefaultAccelerator_,
|
||||||
&accelerator)) {
|
&accelerator)) {
|
||||||
const ui::PlatformAcceleratorCocoa* platformAccelerator =
|
NSString* key_equivalent;
|
||||||
static_cast<const ui::PlatformAcceleratorCocoa*>(
|
NSUInteger modifier_mask;
|
||||||
accelerator.platform_accelerator());
|
GetKeyEquivalentAndModifierMaskFromAccelerator(
|
||||||
if (platformAccelerator) {
|
accelerator, &key_equivalent, &modifier_mask);
|
||||||
[item setKeyEquivalent:platformAccelerator->characters()];
|
[item setKeyEquivalent:key_equivalent];
|
||||||
[item
|
[item setKeyEquivalentModifierMask:modifier_mask];
|
||||||
setKeyEquivalentModifierMask:platformAccelerator->modifier_mask()];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set menu item's role.
|
// Set menu item's role.
|
||||||
|
|
|
@ -336,8 +336,6 @@ filenames = {
|
||||||
"atom/browser/special_storage_policy.h",
|
"atom/browser/special_storage_policy.h",
|
||||||
"atom/browser/ui/accelerator_util.cc",
|
"atom/browser/ui/accelerator_util.cc",
|
||||||
"atom/browser/ui/accelerator_util.h",
|
"atom/browser/ui/accelerator_util.h",
|
||||||
"atom/browser/ui/accelerator_util_mac.mm",
|
|
||||||
"atom/browser/ui/accelerator_util_views.cc",
|
|
||||||
"atom/browser/ui/atom_menu_model.cc",
|
"atom/browser/ui/atom_menu_model.cc",
|
||||||
"atom/browser/ui/atom_menu_model.h",
|
"atom/browser/ui/atom_menu_model.h",
|
||||||
"atom/browser/ui/autofill_popup.cc",
|
"atom/browser/ui/autofill_popup.cc",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue