按键区
按键区是键盘的主要区域,用于放置各种按键。
按键区配置属性
Section titled “按键区配置属性”keyboardHeight:用于定义按键区的高度,类型Int,单位为点(points)。keyboardStyle: 用于定义按键区的样式。类型:Object- insets: 可选,用于定义按键区的内边距,类型:
Object,默认为空,表示无内边距。- top: 可选,类型:
Int,单位为点(points)。 - left: 可选,类型:
Int,单位为点(points)。 - bottom: 可选,类型:
Int,单位为点(points)。 - right: 可选,类型:
Int,单位为点(points)。
- top: 可选,类型:
backgroundStyle:可选,类型:String,引用一个样式,用于定义按键区的背景样式
- insets: 可选,用于定义按键区的内边距,类型:
keyboardLayout: 用于定义按键区的布局,类型:Array,值为一个布局对象数组。
配置示例:
keyboardStyle: insets: {left: 2, right: 2, top: 2, bottom: 2} backgroundStyle: keyboardBackgroundStylekeyboardLayout: - HStack: subviews: - Cell: qButton - Cell: wButton - Cell: eButton - Cell: rButton - Cell: tButton - Cell: yButton - Cell: uButton - Cell: iButton - Cell: oButton - Cell: pButton - HStack: subviews: - Cell: aButton - Cell: sButton - Cell: dButton - Cell: fButton - Cell: gButton - Cell: hButton - Cell: jButton - Cell: kButton - Cell: lButton - HStack: subviews: - Cell: shiftButton - Cell: zButton - Cell: xButton - Cell: cButton - Cell: vButton - Cell: bButton - Cell: nButton - Cell: mButton - Cell: backspaceButton - HStack: subviews: - Cell: 123Button - Cell: spaceButton - Cell: enterButton分体键盘(Split)
Section titled “分体键盘(Split)”分体键盘指键盘可以从中间分开,也可以重新合并,类似物理分体式键盘。该功能不限设备、方向与键盘类型,通过指令 #toggleSplitState 切换;切换后键盘按新状态整体重建。
Split 态下键盘长什么样完全由皮肤决定:皮肤在哪些样式里写了 split 配置,Split 就在哪些样式上生效;没写 split 的样式,外观及行为相同。
为皮肤适配 Split 是可选的——不写任何 split 配置,皮肤在两种状态下表现不变。
split 覆盖块
Section titled “split 覆盖块”任意样式节点(不限于按键区,长按气泡、工具栏、候选栏、符号栏所引用的样式同样适用)都可以在自身内新增一个可选的 split 字段,用来声明”仅在 Split 状态下生效”的覆盖值:
qKey: size: { width: '112.5/1125' } normalColor: '#FFFFFF' split: size: { width: '180/1125' } # 仅 Split 状态下生效注意:
split块内可以放任意字段,如cornerRadius、fontSize、visualFrame、foregroundStyle、action等。
分体键盘中间的缝隙,通过一颗平时零宽、Split 态下撑开的按键来实现:
splitGap: size: { width: 0 } split: # 根据设计在这里调整缝隙大小 size: { width: '150/1125' }一行(或一列)的总宽度(或高度)是固定的,皮肤里每颗键写的 width(或 height),含义是”占这一行(列)的多少”。因此 Split 状态下一行内所有键的宽度加起来,必须正好等于整行宽度,多写或少写都需要皮肤作者自行核算。
例外:没有显式声明 width 的键,会自动获得”剩余空间”,不需要手工核算,也不参与总宽度的加总。
配置超额(总和大于容器宽度)时不会报错,超出的部分也不会被自动吸收,渲染结果一定是错的——常见表现为键被挤出显示区域。