feat: show user gesture type in click event (#16954)

This commit is contained in:
Shelley Vohr 2019-02-20 12:20:24 +00:00 committed by GitHub
parent cc5ed24e23
commit 3edc497d3d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 1 deletions

View file

@ -79,6 +79,7 @@ v8::Local<v8::Object> CreateEventFromFlags(v8::Isolate* isolate, int flags) {
obj.Set("ctrlKey", static_cast<bool>(flags & ui::EF_CONTROL_DOWN)); obj.Set("ctrlKey", static_cast<bool>(flags & ui::EF_CONTROL_DOWN));
obj.Set("altKey", static_cast<bool>(flags & ui::EF_ALT_DOWN)); obj.Set("altKey", static_cast<bool>(flags & ui::EF_ALT_DOWN));
obj.Set("metaKey", static_cast<bool>(flags & ui::EF_COMMAND_DOWN)); obj.Set("metaKey", static_cast<bool>(flags & ui::EF_COMMAND_DOWN));
obj.Set("triggeredByAccelerator", static_cast<bool>(flags));
return obj.GetHandle(); return obj.GetHandle();
} }

View file

@ -4,3 +4,4 @@
* `metaKey` Boolean (optional) - whether a meta key was used in an accelerator to trigger the Event * `metaKey` Boolean (optional) - whether a meta key was used in an accelerator to trigger the Event
* `shiftKey` Boolean (optional) - whether a Shift key was used in an accelerator to trigger the Event * `shiftKey` Boolean (optional) - whether a Shift key was used in an accelerator to trigger the Event
* `altKey` Boolean (optional) - whether an Alt key was used in an accelerator to trigger the Event * `altKey` Boolean (optional) - whether an Alt key was used in an accelerator to trigger the Event
* `triggeredByAccelerator` Boolean (optional) - whether an accelerator was used to trigger the event as opposed to another user gesture like mouse click

View file

@ -31,7 +31,7 @@ const delegate = {
command.click(event, TopLevelWindow.getFocusedWindow(), webContents.getFocusedWebContents()) command.click(event, TopLevelWindow.getFocusedWindow(), webContents.getFocusedWebContents())
}, },
menuWillShow: (menu) => { menuWillShow: (menu) => {
// Ensure radio groups have at least one menu item seleted // Ensure radio groups have at least one menu item selected
for (const id in menu.groupsMap) { for (const id in menu.groupsMap) {
const found = menu.groupsMap[id].find(item => item.checked) || null const found = menu.groupsMap[id].find(item => item.checked) || null
if (!found) v8Util.setHiddenValue(menu.groupsMap[id][0], 'checked', true) if (!found) v8Util.setHiddenValue(menu.groupsMap[id][0], 'checked', true)