feat: add support for keyboard initialized menu popup (#38903)
* feat: add support for keyboard initialized menu popup * Update docs/api/menu.md Co-authored-by: Erick Zhao <erick@hotmail.ca> * fix: add patch to chromium for keyboard accessibility menu behavior * refactor: s/initiatedByKeyboard/sourceType * fix: ignore initial mouse event to retain keyboard initiated focus * Update docs/api/menu.md Co-authored-by: Samuel Maddock <samuel.maddock@gmail.com> --------- Co-authored-by: Erick Zhao <erick@hotmail.ca> Co-authored-by: Samuel Maddock <samuel.maddock@gmail.com>
This commit is contained in:
parent
607e71d563
commit
499d893040
13 changed files with 282 additions and 33 deletions
|
@ -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 };
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue