Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
33a0015c
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,体验更适合开发者的 AI 搜索 >>
提交
33a0015c
编写于
2月 23, 2018
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
notifications - keyboard navigation in buttons
上级
ce13bb0d
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
87 addition
and
32 deletion
+87
-32
src/vs/base/browser/ui/button/button.ts
src/vs/base/browser/ui/button/button.ts
+61
-5
src/vs/workbench/browser/parts/notifications/notificationsToasts.ts
...kbench/browser/parts/notifications/notificationsToasts.ts
+3
-3
src/vs/workbench/browser/parts/notifications/notificationsViewer.ts
...kbench/browser/parts/notifications/notificationsViewer.ts
+19
-20
src/vs/workbench/parts/files/electron-browser/views/emptyView.ts
...workbench/parts/files/electron-browser/views/emptyView.ts
+1
-1
src/vs/workbench/parts/search/browser/searchWidget.ts
src/vs/workbench/parts/search/browser/searchWidget.ts
+3
-3
未找到文件。
src/vs/base/browser/ui/button/button.ts
浏览文件 @
33a0015c
...
...
@@ -13,6 +13,7 @@ import { KeyCode } from 'vs/base/common/keyCodes';
import
{
Color
}
from
'
vs/base/common/color
'
;
import
{
mixin
}
from
'
vs/base/common/objects
'
;
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
dispose
,
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
export
interface
IButtonOptions
extends
IButtonStyles
{
}
...
...
@@ -61,7 +62,7 @@ export class Button {
'
role
'
:
'
button
'
}).
appendTo
(
container
);
this
.
$el
.
on
(
DOM
.
EventType
.
CLICK
,
(
e
)
=>
{
this
.
$el
.
on
(
DOM
.
EventType
.
CLICK
,
e
=>
{
if
(
!
this
.
enabled
)
{
DOM
.
EventHelper
.
stop
(
e
);
return
;
...
...
@@ -70,7 +71,7 @@ export class Button {
this
.
_onDidClick
.
fire
(
e
);
});
this
.
$el
.
on
(
DOM
.
EventType
.
KEY_DOWN
,
(
e
)
=>
{
this
.
$el
.
on
(
DOM
.
EventType
.
KEY_DOWN
,
e
=>
{
let
event
=
new
StandardKeyboardEvent
(
e
as
KeyboardEvent
);
let
eventHandled
=
false
;
if
(
this
.
enabled
&&
event
.
equals
(
KeyCode
.
Enter
)
||
event
.
equals
(
KeyCode
.
Space
))
{
...
...
@@ -86,13 +87,13 @@ export class Button {
}
});
this
.
$el
.
on
(
DOM
.
EventType
.
MOUSE_OVER
,
(
e
)
=>
{
this
.
$el
.
on
(
DOM
.
EventType
.
MOUSE_OVER
,
e
=>
{
if
(
!
this
.
$el
.
hasClass
(
'
disabled
'
))
{
this
.
setHoverBackground
();
}
});
this
.
$el
.
on
(
DOM
.
EventType
.
MOUSE_OUT
,
(
e
)
=>
{
this
.
$el
.
on
(
DOM
.
EventType
.
MOUSE_OUT
,
e
=>
{
this
.
applyStyles
();
// restore standard styles
});
...
...
@@ -135,7 +136,7 @@ export class Button {
}
}
get
E
lement
():
HTMLElement
{
get
e
lement
():
HTMLElement
{
return
this
.
$el
.
getHTMLElement
();
}
...
...
@@ -183,4 +184,59 @@ export class Button {
this
.
_onDidClick
.
dispose
();
}
}
export
class
ButtonGroup
{
private
_buttons
:
Button
[];
private
toDispose
:
IDisposable
[];
constructor
(
container
:
Builder
,
count
:
number
,
options
?:
IButtonOptions
);
constructor
(
container
:
HTMLElement
,
count
:
number
,
options
?:
IButtonOptions
);
constructor
(
container
:
any
,
count
:
number
,
options
?:
IButtonOptions
)
{
this
.
_buttons
=
[];
this
.
toDispose
=
[];
this
.
create
(
container
,
count
,
options
);
}
get
buttons
():
Button
[]
{
return
this
.
_buttons
;
}
private
create
(
container
:
Builder
,
count
:
number
,
options
?:
IButtonOptions
):
void
;
private
create
(
container
:
HTMLElement
,
count
:
number
,
options
?:
IButtonOptions
):
void
;
private
create
(
container
:
any
,
count
:
number
,
options
?:
IButtonOptions
):
void
{
for
(
let
index
=
0
;
index
<
count
;
index
++
)
{
const
button
=
new
Button
(
container
,
options
);
this
.
_buttons
.
push
(
button
);
this
.
toDispose
.
push
(
button
);
// Implement keyboard access in buttons if there are multiple
if
(
count
>
1
)
{
$
(
button
.
element
).
on
(
DOM
.
EventType
.
KEY_DOWN
,
e
=>
{
const
event
=
new
StandardKeyboardEvent
(
e
as
KeyboardEvent
);
let
eventHandled
=
true
;
// Next / Previous Button
let
buttonIndexToFocus
:
number
;
if
(
event
.
equals
(
KeyCode
.
LeftArrow
))
{
buttonIndexToFocus
=
index
>
0
?
index
-
1
:
this
.
_buttons
.
length
-
1
;
}
else
if
(
event
.
equals
(
KeyCode
.
RightArrow
))
{
buttonIndexToFocus
=
index
===
this
.
_buttons
.
length
-
1
?
0
:
index
+
1
;
}
else
{
eventHandled
=
false
;
}
if
(
eventHandled
)
{
this
.
_buttons
[
buttonIndexToFocus
].
focus
();
DOM
.
EventHelper
.
stop
(
e
,
true
);
}
},
this
.
toDispose
);
}
}
}
dispose
():
void
{
this
.
toDispose
=
dispose
(
this
.
toDispose
);
}
}
\ No newline at end of file
src/vs/workbench/browser/parts/notifications/notificationsToasts.ts
浏览文件 @
33a0015c
...
...
@@ -36,12 +36,12 @@ interface INotificationToast {
export
class
NotificationsToasts
extends
Themable
{
private
static
MAX_WIDTH
=
450
;
private
static
MAX_NOTIFICATIONS
=
4
;
private
static
MAX_NOTIFICATIONS
=
3
;
private
static
PURGE_TIMEOUT
:
{
[
severity
:
number
]:
number
}
=
(()
=>
{
const
intervals
=
Object
.
create
(
null
);
intervals
[
Severity
.
Info
]
=
8
000
;
intervals
[
Severity
.
Warning
]
=
1
2
000
;
intervals
[
Severity
.
Info
]
=
5
000
;
intervals
[
Severity
.
Warning
]
=
1
0
000
;
intervals
[
Severity
.
Error
]
=
15000
;
return
intervals
;
...
...
src/vs/workbench/browser/parts/notifications/notificationsViewer.ts
浏览文件 @
33a0015c
...
...
@@ -12,7 +12,7 @@ import { IOpenerService } from 'vs/platform/opener/common/opener';
import
URI
from
'
vs/base/common/uri
'
;
import
{
onUnexpectedError
}
from
'
vs/base/common/errors
'
;
import
{
localize
}
from
'
vs/nls
'
;
import
{
Button
}
from
'
vs/base/browser/ui/button/button
'
;
import
{
Button
Group
}
from
'
vs/base/browser/ui/button/button
'
;
import
{
attachButtonStyler
,
attachProgressBarStyler
}
from
'
vs/platform/theme/common/styler
'
;
import
{
IThemeService
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
IMarkdownString
}
from
'
vs/base/common/htmlContent
'
;
...
...
@@ -396,7 +396,24 @@ export class NotificationTemplateRenderer {
clearNode
(
this
.
template
.
buttonsContainer
);
if
(
notification
.
expanded
)
{
notification
.
actions
.
primary
.
forEach
(
action
=>
this
.
createButton
(
notification
,
action
));
const
buttonGroup
=
new
ButtonGroup
(
this
.
template
.
buttonsContainer
,
notification
.
actions
.
primary
.
length
);
buttonGroup
.
buttons
.
forEach
((
button
,
index
)
=>
{
const
action
=
notification
.
actions
.
primary
[
index
];
button
.
label
=
action
.
label
;
this
.
inputDisposeables
.
push
(
button
.
onDidClick
(()
=>
{
// Run action
this
.
actionRunner
.
run
(
action
,
notification
);
// Hide notification
notification
.
dispose
();
}));
this
.
inputDisposeables
.
push
(
attachButtonStyler
(
button
,
this
.
themeService
));
});
this
.
inputDisposeables
.
push
(
buttonGroup
);
}
}
...
...
@@ -449,24 +466,6 @@ export class NotificationTemplateRenderer {
return
keybinding
?
keybinding
.
getLabel
()
:
void
0
;
}
private
createButton
(
notification
:
INotificationViewItem
,
action
:
IAction
):
Button
{
const
button
=
new
Button
(
this
.
template
.
buttonsContainer
);
button
.
label
=
action
.
label
;
this
.
inputDisposeables
.
push
(
button
.
onDidClick
(()
=>
{
// Run action
this
.
actionRunner
.
run
(
action
,
notification
);
// Hide notification
notification
.
dispose
();
}));
this
.
inputDisposeables
.
push
(
attachButtonStyler
(
button
,
this
.
themeService
));
this
.
inputDisposeables
.
push
(
button
);
return
button
;
}
public
dispose
():
void
{
this
.
inputDisposeables
=
dispose
(
this
.
inputDisposeables
);
}
...
...
src/vs/workbench/parts/files/electron-browser/views/emptyView.ts
浏览文件 @
33a0015c
...
...
@@ -102,7 +102,7 @@ export class EmptyView extends ViewsViewletPanel {
public
focusBody
():
void
{
if
(
this
.
button
)
{
this
.
button
.
getElement
()
.
focus
();
this
.
button
.
element
.
focus
();
}
}
...
...
src/vs/workbench/parts/search/browser/searchWidget.ts
浏览文件 @
33a0015c
...
...
@@ -225,7 +225,7 @@ export class SearchWidget extends Widget {
this
.
toggleReplaceButton
.
icon
=
'
toggle-replace-button collapse
'
;
// TODO@joh need to dispose this listener eventually
this
.
toggleReplaceButton
.
onDidClick
(()
=>
this
.
onToggleReplaceButton
());
this
.
toggleReplaceButton
.
getElement
()
.
title
=
nls
.
localize
(
'
search.replace.toggle.button.title
'
,
"
Toggle Replace
"
);
this
.
toggleReplaceButton
.
element
.
title
=
nls
.
localize
(
'
search.replace.toggle.button.title
'
,
"
Toggle Replace
"
);
}
private
renderSearchInput
(
parent
:
HTMLElement
,
options
:
ISearchWidgetOptions
):
void
{
...
...
@@ -301,8 +301,8 @@ export class SearchWidget extends Widget {
private
onToggleReplaceButton
():
void
{
dom
.
toggleClass
(
this
.
replaceContainer
,
'
disabled
'
);
dom
.
toggleClass
(
this
.
toggleReplaceButton
.
getElement
()
,
'
collapse
'
);
dom
.
toggleClass
(
this
.
toggleReplaceButton
.
getElement
()
,
'
expand
'
);
dom
.
toggleClass
(
this
.
toggleReplaceButton
.
element
,
'
collapse
'
);
dom
.
toggleClass
(
this
.
toggleReplaceButton
.
element
,
'
expand
'
);
this
.
updateReplaceActiveState
();
this
.
_onReplaceToggled
.
fire
();
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录