Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
ec18a3e1
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ec18a3e1
编写于
7月 11, 2018
作者:
S
SteVen Batten
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixes #54047
上级
0247a861
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
48 addition
and
47 deletion
+48
-47
src/vs/workbench/browser/parts/menubar/menubarPart.ts
src/vs/workbench/browser/parts/menubar/menubarPart.ts
+48
-47
未找到文件。
src/vs/workbench/browser/parts/menubar/menubarPart.ts
浏览文件 @
ec18a3e1
...
...
@@ -103,7 +103,6 @@ export class MenubarPart extends Part {
private
container
:
Builder
;
private
recentlyOpened
:
IRecentlyOpened
;
private
updatePending
:
boolean
;
private
focusingWithAlt
:
boolean
;
private
_modifierKeyStatus
:
IModifierKeyStatus
;
private
_focusState
:
MenubarState
;
...
...
@@ -343,8 +342,8 @@ export class MenubarPart extends Part {
}
private
onModifierKeyToggled
(
modifierKeyStatus
:
IModifierKeyStatus
):
void
{
const
altKeyPressed
=
(
!
this
.
_modifierKeyStatus
||
!
this
.
_modifierKeyStatus
.
altKey
)
&&
modifierKeyStatus
.
altKey
;
const
altKeyAlone
=
altKeyPressed
&&
!
modifierKeyStatus
.
ctrlKey
&&
!
modifierKeyStatus
.
shiftKey
;
this
.
_modifierKeyStatus
=
modifierKeyStatus
;
const
altKeyAlone
=
modifierKeyStatus
.
lastKeyPressed
===
'
alt
'
&&
!
modifierKeyStatus
.
ctrlKey
&&
!
modifierKeyStatus
.
shiftKey
;
const
allModifiersReleased
=
!
modifierKeyStatus
.
altKey
&&
!
modifierKeyStatus
.
ctrlKey
&&
!
modifierKeyStatus
.
shiftKey
;
if
(
this
.
currentMenubarVisibility
===
'
toggle
'
)
{
...
...
@@ -357,7 +356,7 @@ export class MenubarPart extends Part {
}
}
if
(
allModifiersReleased
&&
this
.
focusingWithAlt
)
{
if
(
allModifiersReleased
&&
modifierKeyStatus
.
lastKeyPressed
===
'
alt
'
&&
modifierKeyStatus
.
lastKeyReleased
===
'
alt
'
)
{
if
(
!
this
.
isFocused
)
{
this
.
focusedMenu
=
{
index
:
0
};
this
.
focusState
=
MenubarState
.
FOCUSED
;
...
...
@@ -366,8 +365,6 @@ export class MenubarPart extends Part {
}
}
this
.
_modifierKeyStatus
=
modifierKeyStatus
;
if
(
this
.
currentEnableMenuBarMnemonics
&&
this
.
customMenus
)
{
this
.
customMenus
.
forEach
(
customMenu
=>
{
let
child
=
customMenu
.
titleElement
.
child
();
...
...
@@ -376,8 +373,6 @@ export class MenubarPart extends Part {
}
});
}
this
.
focusingWithAlt
=
altKeyAlone
;
}
private
onRecentlyOpenedChange
():
void
{
...
...
@@ -975,74 +970,80 @@ export class MenubarPart extends Part {
}
}
type
ModifierKey
=
'
alt
'
|
'
ctrl
'
|
'
shift
'
;
interface
IModifierKeyStatus
{
altKey
:
boolean
;
shiftKey
:
boolean
;
ctrlKey
:
boolean
;
lastKeyPressed
?:
ModifierKey
;
lastKeyReleased
?:
ModifierKey
;
}
class
ModifierKeyEmitter
extends
Emitter
<
IModifierKeyStatus
>
{
private
_subscriptions
:
IDisposable
[]
=
[];
private
_
isPressed
:
IModifierKeyStatus
;
private
_
keyStatus
:
IModifierKeyStatus
;
private
static
instance
:
ModifierKeyEmitter
;
private
constructor
()
{
super
();
this
.
_
isPressed
=
{
this
.
_
keyStatus
=
{
altKey
:
false
,
shiftKey
:
false
,
ctrlKey
:
false
};
this
.
_subscriptions
.
push
(
domEvent
(
document
.
body
,
'
keydown
'
)(
e
=>
{
if
(
e
.
altKey
||
e
.
shiftKey
||
e
.
ctrlKey
)
{
this
.
isPressed
=
{
altKey
:
e
.
altKey
,
ctrlKey
:
e
.
ctrlKey
,
shiftKey
:
e
.
shiftKey
};
if
(
e
.
altKey
&&
!
this
.
_keyStatus
.
altKey
)
{
this
.
_keyStatus
.
lastKeyPressed
=
'
alt
'
;
}
else
if
(
e
.
ctrlKey
&&
!
this
.
_keyStatus
.
ctrlKey
)
{
this
.
_keyStatus
.
lastKeyPressed
=
'
ctrl
'
;
}
else
if
(
e
.
shiftKey
&&
!
this
.
_keyStatus
.
shiftKey
)
{
this
.
_keyStatus
.
lastKeyPressed
=
'
shift
'
;
}
else
{
this
.
_keyStatus
.
lastKeyPressed
=
undefined
;
}
this
.
_keyStatus
.
altKey
=
e
.
altKey
;
this
.
_keyStatus
.
ctrlKey
=
e
.
ctrlKey
;
this
.
_keyStatus
.
shiftKey
=
e
.
shiftKey
;
if
(
this
.
_keyStatus
.
lastKeyPressed
)
{
this
.
fire
(
this
.
_keyStatus
);
}
}));
this
.
_subscriptions
.
push
(
domEvent
(
document
.
body
,
'
keyup
'
)(
e
=>
{
if
((
!
e
.
altKey
&&
this
.
isPressed
.
altKey
)
||
(
!
e
.
shiftKey
&&
this
.
isPressed
.
shiftKey
)
||
(
!
e
.
ctrlKey
&&
this
.
isPressed
.
ctrlKey
)
)
{
this
.
isPressed
=
{
altKey
:
e
.
altKey
,
shiftKey
:
e
.
shiftKey
,
ctrlKey
:
e
.
ctrlKey
};
if
(
!
e
.
altKey
&&
this
.
_keyStatus
.
altKey
)
{
this
.
_keyStatus
.
lastKeyReleased
=
'
alt
'
;
}
else
if
(
!
e
.
ctrlKey
&&
this
.
_keyStatus
.
ctrlKey
)
{
this
.
_keyStatus
.
lastKeyReleased
=
'
ctrl
'
;
}
else
if
(
!
e
.
shiftKey
&&
this
.
_keyStatus
.
shiftKey
)
{
this
.
_keyStatus
.
lastKeyReleased
=
'
shift
'
;
}
else
{
this
.
_keyStatus
.
lastKeyReleased
=
undefined
;
}
}));
this
.
_subscriptions
.
push
(
domEvent
(
document
.
body
,
'
blur
'
)(
e
=>
{
if
(
this
.
isPressed
.
altKey
||
this
.
isPressed
.
shiftKey
||
this
.
isPressed
.
ctrlKey
)
{
this
.
isPressed
=
{
altKey
:
false
,
shiftKey
:
false
,
ctrlKey
:
false
};
this
.
_keyStatus
.
altKey
=
e
.
altKey
;
this
.
_keyStatus
.
ctrlKey
=
e
.
ctrlKey
;
this
.
_keyStatus
.
shiftKey
=
e
.
shiftKey
;
if
(
this
.
_keyStatus
.
lastKeyReleased
)
{
this
.
fire
(
this
.
_keyStatus
);
}
}));
}
get
isPressed
():
IModifierKeyStatus
{
return
this
.
_isPressed
;
}
this
.
_subscriptions
.
push
(
domEvent
(
window
,
'
blur
'
)(
e
=>
{
this
.
_keyStatus
.
lastKeyPressed
=
undefined
;
this
.
_keyStatus
.
lastKeyReleased
=
undefined
;
this
.
_keyStatus
.
altKey
=
false
;
this
.
_keyStatus
.
shiftKey
=
false
;
this
.
_keyStatus
.
shiftKey
=
false
;
set
isPressed
(
value
:
IModifierKeyStatus
)
{
if
(
this
.
_isPressed
.
altKey
===
value
.
altKey
&&
this
.
_isPressed
.
shiftKey
===
value
.
shiftKey
&&
this
.
_isPressed
.
ctrlKey
===
value
.
ctrlKey
)
{
return
;
}
this
.
_isPressed
=
value
;
this
.
fire
(
this
.
_isPressed
);
this
.
fire
(
this
.
_keyStatus
);
}));
}
static
getInstance
()
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录