Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
64487915
D
Docs
项目概览
OpenHarmony
/
Docs
大约 2 年 前同步成功
通知
161
Star
293
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
64487915
编写于
6月 09, 2022
作者:
O
openharmony_ci
提交者:
Gitee
6月 09, 2022
浏览文件
操作
浏览文件
下载
差异文件
!5137 Feature:支持tabIndex走焦功能
Merge pull request !5137 from bixuefeng/feature_tabindex_0607
上级
f6a59e40
73e59a34
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
29 addition
and
38 deletion
+29
-38
zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-focus.md
...n-dev/reference/arkui-ts/ts-universal-attributes-focus.md
+29
-38
未找到文件。
zh-cn/application-dev/reference/arkui-ts/ts-universal-attributes-focus.md
浏览文件 @
64487915
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
|
**名称**
|
**参数类型**
|
**默认值**
|
**描述**
|
|
**名称**
|
**参数类型**
|
**默认值**
|
**描述**
|
| -------- | -------- | -------- | -------- |
| -------- | -------- | -------- | -------- |
| focusable | boolean | false | 设置当前组件是否可以获焦。 |
| focusable | boolean | false | 设置当前组件是否可以获焦。 |
| tabIndex
<sup>
9+
<sup>
| number | 0 | 自定义组件tab键走焦能力,走焦顺序为:tabIndex大于0的组件依次递增走焦, tabIndex等于0的组件按组件树先后顺序走焦。
<br
/>
- tabIndex >= 0:表示元素是可聚焦的,并且可以通过tab键走焦来访问到该元素,按照tabIndex的数值递增而先后获焦。如果多个元素拥有相同的tabIndex,按照元素在当前组件树中的先后顺序获焦
<br
/>
- tabIndex < 0(通常是tabIndex = -1):表示元素是可聚焦的,但是不能通过tab键走焦来访问到该元素 |
> **说明:**
> **说明:**
> 支持焦点控制的组件:Button、Text、Image、List、Grid。
> 支持焦点控制的组件:Button、Text、Image、List、Grid。
...
@@ -26,51 +27,41 @@
...
@@ -26,51 +27,41 @@
@
Entry
@
Entry
@
Component
@
Component
struct
FocusableExample
{
struct
FocusableExample
{
@
State
textOne
:
string
=
''
@
State
text1
:
string
=
'
TabIndex=3
'
@
State
textTwo
:
string
=
''
@
State
text2
:
string
=
'
TabIndex=2
'
@
State
textThree
:
string
=
'
The third button cannot be focused
'
@
State
text3
:
string
=
'
focusable=false
'
@
State
oneButtonColor
:
string
=
'
#FF0000
'
@
State
text4
:
string
=
'
TabIndex=-1
'
@
State
twoButtonColor
:
string
=
'
#FFC0CB
'
@
State
text5
:
string
=
'
TabIndex=1
'
@
State
threeButtonColor
:
string
=
'
#87CEFA
'
@
State
text6
:
string
=
'
TabIndex=1
'
@
State
text7
:
string
=
'
focusable=true
'
@
State
text8
:
string
=
'
focusable=true
'
build
()
{
build
()
{
Column
({
space
:
20
}){
Column
({
space
:
20
}){
Button
(
this
.
textOne
)
Button
(
this
.
text1
)
// 按下TAB键第四个获焦的组件
.
backgroundColor
(
this
.
oneButtonColor
)
.
width
(
300
).
height
(
70
).
fontColor
(
Color
.
Black
)
.
width
(
300
).
height
(
70
).
fontColor
(
Color
.
Black
)
.
focusable
(
true
)
.
tabIndex
(
3
)
.
onFocus
(()
=>
{
Button
(
this
.
text2
)
// 按下TAB键第三个获焦的组件
this
.
textOne
=
'
First Button onFocus
'
this
.
oneButtonColor
=
'
#AFEEEE
'
})
.
onBlur
(()
=>
{
this
.
textOne
=
'
First Button onBlur
'
this
.
oneButtonColor
=
'
#FFC0CB
'
})
Button
(
this
.
textTwo
)
.
backgroundColor
(
this
.
twoButtonColor
)
.
width
(
300
).
height
(
70
).
fontColor
(
Color
.
Black
)
.
width
(
300
).
height
(
70
).
fontColor
(
Color
.
Black
)
.
focusable
(
true
)
.
tabIndex
(
2
)
.
onFocus
(()
=>
{
Button
(
this
.
text3
)
// 无法获焦的组件
this
.
textTwo
=
'
Second Button onFocus
'
this
.
twoButtonColor
=
'
#AFEEEE
'
})
.
onBlur
(()
=>
{
this
.
textTwo
=
'
Second Button onBlur
'
this
.
twoButtonColor
=
'
#FFC0CB
'
})
Button
(
this
.
textThree
)
.
backgroundColor
(
this
.
threeButtonColor
)
.
width
(
300
).
height
(
70
).
fontColor
(
Color
.
Black
)
.
width
(
300
).
height
(
70
).
fontColor
(
Color
.
Black
)
.
focusable
(
false
)
.
focusable
(
false
)
.
onFocus
(()
=>
{
Button
(
this
.
text4
)
// 无法使用TAB键,但可以使用方向键走焦的组件
this
.
textThree
=
'
Third Button onFocus
'
.
width
(
300
).
height
(
70
).
fontColor
(
Color
.
Black
)
this
.
threeButtonColor
=
'
#AFEEEE
'
.
tabIndex
(
-
1
)
})
Button
(
this
.
text5
)
// 按下TAB键第一个获焦的组件
.
onBlur
(()
=>
{
.
width
(
300
).
height
(
70
).
fontColor
(
Color
.
Black
)
this
.
textThree
=
'
Third Button onBlur
'
.
tabIndex
(
1
)
this
.
threeButtonColor
=
'
#FFC0CB
'
Button
(
this
.
text6
)
// 按下TAB键第二个获焦的组件
})
.
width
(
300
).
height
(
70
).
fontColor
(
Color
.
Black
)
.
tabIndex
(
1
)
Button
(
this
.
text7
)
// 按下TAB键第五个获焦的组件
.
width
(
300
).
height
(
70
).
fontColor
(
Color
.
Black
)
.
focusable
(
true
)
Button
(
this
.
text8
)
// 按下TAB键第六个获焦的组件
.
width
(
300
).
height
(
70
).
fontColor
(
Color
.
Black
)
.
focusable
(
true
)
}.
width
(
'
100%
'
).
margin
({
top
:
20
})
}.
width
(
'
100%
'
).
margin
({
top
:
20
})
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录