fix: keep shifted character in menu accelerator (#29202)
* fix: correctly handle shifted char in accelerator * test: use actual accelerator of NSMenuItem * chore: simplify KeyboardCodeFromStr * chore: GetAcceleratorTextAt is testing only
This commit is contained in:
parent
31190d4c6d
commit
3cfe5c6a21
11 changed files with 168 additions and 83 deletions
|
@ -462,9 +462,9 @@ describe('MenuItems', () => {
|
|||
{ label: 'text', accelerator: 'Alt+A' }
|
||||
]);
|
||||
|
||||
expect(menu.getAcceleratorTextAt(0)).to.equal(isDarwin() ? '⌘A' : 'Ctrl+A');
|
||||
expect(menu.getAcceleratorTextAt(1)).to.equal(isDarwin() ? '⇧A' : 'Shift+A');
|
||||
expect(menu.getAcceleratorTextAt(2)).to.equal(isDarwin() ? '⌥A' : 'Alt+A');
|
||||
expect(menu.getAcceleratorTextAt(0)).to.equal(isDarwin() ? 'Command+A' : 'Ctrl+A');
|
||||
expect(menu.getAcceleratorTextAt(1)).to.equal('Shift+A');
|
||||
expect(menu.getAcceleratorTextAt(2)).to.equal('Alt+A');
|
||||
});
|
||||
|
||||
it('should display modifiers correctly for special keys', () => {
|
||||
|
@ -474,9 +474,9 @@ describe('MenuItems', () => {
|
|||
{ label: 'text', accelerator: 'Alt+Tab' }
|
||||
]);
|
||||
|
||||
expect(menu.getAcceleratorTextAt(0)).to.equal(isDarwin() ? '⌘⇥' : 'Ctrl+Tab');
|
||||
expect(menu.getAcceleratorTextAt(1)).to.equal(isDarwin() ? '⇧⇥' : 'Shift+Tab');
|
||||
expect(menu.getAcceleratorTextAt(2)).to.equal(isDarwin() ? '⌥⇥' : 'Alt+Tab');
|
||||
expect(menu.getAcceleratorTextAt(0)).to.equal(isDarwin() ? 'Command+Tab' : 'Ctrl+Tab');
|
||||
expect(menu.getAcceleratorTextAt(1)).to.equal('Shift+Tab');
|
||||
expect(menu.getAcceleratorTextAt(2)).to.equal('Alt+Tab');
|
||||
});
|
||||
|
||||
it('should not display modifiers twice', () => {
|
||||
|
@ -485,18 +485,26 @@ describe('MenuItems', () => {
|
|||
{ label: 'text', accelerator: 'Shift+Shift+Tab' }
|
||||
]);
|
||||
|
||||
expect(menu.getAcceleratorTextAt(0)).to.equal(isDarwin() ? '⇧A' : 'Shift+A');
|
||||
expect(menu.getAcceleratorTextAt(1)).to.equal(isDarwin() ? '⇧⇥' : 'Shift+Tab');
|
||||
expect(menu.getAcceleratorTextAt(0)).to.equal('Shift+A');
|
||||
expect(menu.getAcceleratorTextAt(1)).to.equal('Shift+Tab');
|
||||
});
|
||||
|
||||
it('should display correctly for edge cases', () => {
|
||||
it('should display correctly for shifted keys', () => {
|
||||
const menu = Menu.buildFromTemplate([
|
||||
{ label: 'text', accelerator: 'Control+Shift+=' },
|
||||
{ label: 'text', accelerator: 'Control+Plus' }
|
||||
{ label: 'text', accelerator: 'Control+Plus' },
|
||||
{ label: 'text', accelerator: 'Control+Shift+3' },
|
||||
{ label: 'text', accelerator: 'Control+#' },
|
||||
{ label: 'text', accelerator: 'Control+Shift+/' },
|
||||
{ label: 'text', accelerator: 'Control+?' }
|
||||
]);
|
||||
|
||||
expect(menu.getAcceleratorTextAt(0)).to.equal(isDarwin() ? '⌃⇧=' : 'Ctrl+Shift+=');
|
||||
expect(menu.getAcceleratorTextAt(1)).to.equal(isDarwin() ? '⌃⇧=' : 'Ctrl+Shift+=');
|
||||
expect(menu.getAcceleratorTextAt(0)).to.equal('Ctrl+Shift+=');
|
||||
expect(menu.getAcceleratorTextAt(1)).to.equal('Ctrl++');
|
||||
expect(menu.getAcceleratorTextAt(2)).to.equal('Ctrl+Shift+3');
|
||||
expect(menu.getAcceleratorTextAt(3)).to.equal('Ctrl+#');
|
||||
expect(menu.getAcceleratorTextAt(4)).to.equal('Ctrl+Shift+/');
|
||||
expect(menu.getAcceleratorTextAt(5)).to.equal('Ctrl+?');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue