mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
feat: add support for keyboard initialized menu popup (#38954)
* feat: add support for keyboard initialized menu popup Co-authored-by: Samuel Attard <marshallofsound@electronjs.org> * Update docs/api/menu.md Co-authored-by: Erick Zhao <erick@hotmail.ca> Co-authored-by: Samuel Attard <sam@electronjs.org> * fix: add patch to chromium for keyboard accessibility menu behavior Co-authored-by: Samuel Attard <marshallofsound@electronjs.org> * refactor: s/initiatedByKeyboard/sourceType Co-authored-by: Samuel Attard <marshallofsound@electronjs.org> * fix: ignore initial mouse event to retain keyboard initiated focus Co-authored-by: Samuel Attard <marshallofsound@electronjs.org> * Update docs/api/menu.md Co-authored-by: Samuel Maddock <samuel.maddock@gmail.com> Co-authored-by: Samuel Attard <sam@electronjs.org> --------- Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Samuel Attard <marshallofsound@electronjs.org> Co-authored-by: Samuel Attard <sam@electronjs.org>
This commit is contained in:
@@ -69,7 +69,7 @@ Menu.prototype.popup = function (options = {}) {
|
||||
if (options == null || typeof options !== 'object') {
|
||||
throw new TypeError('Options must be an object');
|
||||
}
|
||||
let { window, x, y, positioningItem, callback } = options;
|
||||
let { window, x, y, positioningItem, sourceType, callback } = options;
|
||||
|
||||
// no callback passed
|
||||
if (!callback || typeof callback !== 'function') callback = () => {};
|
||||
@@ -78,6 +78,7 @@ Menu.prototype.popup = function (options = {}) {
|
||||
if (typeof x !== 'number') x = -1;
|
||||
if (typeof y !== 'number') y = -1;
|
||||
if (typeof positioningItem !== 'number') positioningItem = -1;
|
||||
if (typeof sourceType !== 'string' || !sourceType) sourceType = 'mouse';
|
||||
|
||||
// find which window to use
|
||||
const wins = BaseWindow.getAllWindows();
|
||||
@@ -91,7 +92,7 @@ Menu.prototype.popup = function (options = {}) {
|
||||
}
|
||||
}
|
||||
|
||||
this.popupAt(window as unknown as BaseWindow, x, y, positioningItem, callback);
|
||||
this.popupAt(window as unknown as BaseWindow, x, y, positioningItem, sourceType, callback);
|
||||
return { browserWindow: window, x, y, position: positioningItem };
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user