Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
f0a966b5
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f0a966b5
编写于
9月 06, 2018
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix #57997
上级
504c890e
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
23 addition
and
29 deletion
+23
-29
src/vs/base/browser/ui/dropdown/dropdown.ts
src/vs/base/browser/ui/dropdown/dropdown.ts
+17
-13
src/vs/base/common/actions.ts
src/vs/base/common/actions.ts
+6
-16
未找到文件。
src/vs/base/browser/ui/dropdown/dropdown.ts
浏览文件 @
f0a966b5
...
...
@@ -10,12 +10,13 @@ import { TPromise } from 'vs/base/common/winjs.base';
import
{
Gesture
,
EventType
as
GestureEventType
}
from
'
vs/base/browser/touch
'
;
import
{
ActionRunner
,
IAction
,
IActionRunner
}
from
'
vs/base/common/actions
'
;
import
{
BaseActionItem
,
IActionItemProvider
}
from
'
vs/base/browser/ui/actionbar/actionbar
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IContextViewProvider
,
IAnchor
}
from
'
vs/base/browser/ui/contextview/contextview
'
;
import
{
IMenuOptions
}
from
'
vs/base/browser/ui/menu/menu
'
;
import
{
ResolvedKeybinding
}
from
'
vs/base/common/keyCodes
'
;
import
{
ResolvedKeybinding
,
KeyCode
}
from
'
vs/base/common/keyCodes
'
;
import
{
EventHelper
,
EventType
,
removeClass
,
addClass
,
append
,
$
,
addDisposableListener
,
addClasses
}
from
'
vs/base/browser/dom
'
;
import
{
IContextMenuDelegate
}
from
'
vs/base/browser/contextmenu
'
;
import
{
StandardKeyboardEvent
}
from
'
vs/base/browser/keyboardEvent
'
;
export
interface
ILabelRenderer
{
(
container
:
HTMLElement
):
IDisposable
;
...
...
@@ -27,8 +28,6 @@ export interface IBaseDropdownOptions {
}
export
class
BaseDropdown
extends
ActionRunner
{
private
_toDispose
:
IDisposable
[]
=
[];
private
_element
:
HTMLElement
;
private
boxContainer
:
HTMLElement
;
private
_label
:
HTMLElement
;
...
...
@@ -52,11 +51,11 @@ export class BaseDropdown extends ActionRunner {
}
[
EventType
.
CLICK
,
EventType
.
MOUSE_DOWN
,
GestureEventType
.
Tap
].
forEach
(
event
=>
{
this
.
_
toDispose
.
push
(
addDisposableListener
(
this
.
_label
,
event
,
e
=>
EventHelper
.
stop
(
e
,
true
)));
// prevent default click behaviour to trigger
this
.
_
register
(
addDisposableListener
(
this
.
_label
,
event
,
e
=>
EventHelper
.
stop
(
e
,
true
)));
// prevent default click behaviour to trigger
});
[
EventType
.
MOUSE_DOWN
,
GestureEventType
.
Tap
].
forEach
(
event
=>
{
this
.
_
toDispose
.
push
(
addDisposableListener
(
this
.
_label
,
event
,
e
=>
{
this
.
_
register
(
addDisposableListener
(
this
.
_label
,
event
,
e
=>
{
if
(
e
instanceof
MouseEvent
&&
e
.
detail
>
1
)
{
return
;
// prevent multiple clicks to open multiple context menus (https://github.com/Microsoft/vscode/issues/41363)
}
...
...
@@ -69,18 +68,25 @@ export class BaseDropdown extends ActionRunner {
}));
});
this
.
_register
(
addDisposableListener
(
this
.
_label
,
EventType
.
KEY_UP
,
e
=>
{
const
event
=
new
StandardKeyboardEvent
(
e
as
KeyboardEvent
);
if
(
event
.
equals
(
KeyCode
.
Enter
)
||
event
.
equals
(
KeyCode
.
Space
))
{
if
(
this
.
visible
)
{
this
.
hide
();
}
else
{
this
.
show
();
}
}
}));
const
cleanupFn
=
labelRenderer
(
this
.
_label
);
if
(
cleanupFn
)
{
this
.
_
toDispose
.
push
(
cleanupFn
);
this
.
_
register
(
cleanupFn
);
}
Gesture
.
addTarget
(
this
.
_label
);
}
get
toDispose
():
IDisposable
[]
{
return
this
.
_toDispose
;
}
get
element
():
HTMLElement
{
return
this
.
_element
;
}
...
...
@@ -109,8 +115,6 @@ export class BaseDropdown extends ActionRunner {
super
.
dispose
();
this
.
hide
();
this
.
_toDispose
=
dispose
(
this
.
toDispose
);
if
(
this
.
boxContainer
)
{
this
.
boxContainer
.
remove
();
this
.
boxContainer
=
null
;
...
...
src/vs/base/common/actions.ts
浏览文件 @
f0a966b5
...
...
@@ -5,7 +5,7 @@
'
use strict
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IDisposable
,
combinedDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IDisposable
,
combinedDisposable
,
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
Event
,
Emitter
}
from
'
vs/base/common/event
'
;
import
{
isThenable
}
from
'
vs/base/common/async
'
;
...
...
@@ -187,18 +187,13 @@ export interface IRunEvent {
error
?:
any
;
}
export
class
ActionRunner
implements
IActionRunner
{
export
class
ActionRunner
extends
Disposable
implements
IActionRunner
{
private
_onDidBeforeRun
=
new
Emitter
<
IRunEvent
>
(
);
p
rivate
_onDidRun
=
new
Emitter
<
IRunEvent
>
();
private
_onDidBeforeRun
=
this
.
_register
(
new
Emitter
<
IRunEvent
>
()
);
p
ublic
get
onDidBeforeRun
():
Event
<
IRunEvent
>
{
return
this
.
_onDidBeforeRun
.
event
;
}
public
get
onDidRun
():
Event
<
IRunEvent
>
{
return
this
.
_onDidRun
.
event
;
}
public
get
onDidBeforeRun
():
Event
<
IRunEvent
>
{
return
this
.
_onDidBeforeRun
.
event
;
}
private
_onDidRun
=
this
.
_register
(
new
Emitter
<
IRunEvent
>
());
public
get
onDidRun
():
Event
<
IRunEvent
>
{
return
this
.
_onDidRun
.
event
;
}
public
run
(
action
:
IAction
,
context
?:
any
):
TPromise
<
any
>
{
if
(
!
action
.
enabled
)
{
...
...
@@ -223,11 +218,6 @@ export class ActionRunner implements IActionRunner {
return
TPromise
.
wrap
(
res
);
}
public
dispose
():
void
{
this
.
_onDidBeforeRun
.
dispose
();
this
.
_onDidRun
.
dispose
();
}
}
export
class
RadioGroup
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录