@shijiu/jsview-vue 0.9.602 → 0.9.684

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/dom/bin/jsview-browser-debug-dom.min.js +1 -1
  2. package/dom/bin/jsview-dom.min.js +1 -1
  3. package/dom/bin/jsview-engine-js-browser.min.js +1 -0
  4. package/dom/target_core_revision.js +4 -4
  5. package/package.json +1 -1
  6. package/samples/Basic/components/text/TextOverflow.vue +10 -5
  7. package/samples/Collision/App.vue +452 -0
  8. package/samples/DemoHomepage/components/BodyFrame.vue +2 -0
  9. package/samples/DemoHomepage/router.js +25 -0
  10. package/samples/DemoHomepage/views/Homepage.vue +3 -10
  11. package/samples/ImpactStop/App.vue +435 -0
  12. package/samples/Input/App.vue +8 -17
  13. package/samples/Input/InputPanel.vue +18 -11
  14. package/samples/Marquee/App.vue +176 -40
  15. package/samples/Marquee/longText.js +14 -0
  16. package/samples/MetroWidgetDemos/Advanced/App.vue +5 -6
  17. package/samples/MetroWidgetDemos/Advanced/ButtonItem.vue +1 -1
  18. package/samples/MetroWidgetDemos/Advanced/Buttons.vue +5 -5
  19. package/samples/MetroWidgetDemos/Advanced/Mixed.vue +4 -4
  20. package/samples/MetroWidgetDemos/Advanced/widgets/Item.vue +83 -0
  21. package/samples/MetroWidgetDemos/Advanced/widgets/WidgetItem.vue +89 -0
  22. package/samples/MetroWidgetDemos/Advanced/{Widgets.vue → widgets/Widgets.vue} +56 -11
  23. package/samples/MetroWidgetDemos/Advanced/widgets/focus1.png +0 -0
  24. package/samples/MetroWidgetDemos/Item.vue +20 -2
  25. package/samples/MetroWidgetDemos/PingPong/App.vue +3 -3
  26. package/samples/MetroWidgetDemos/PingPong/AppPage.vue +17 -2
  27. package/samples/MetroWidgetDemos/PingPong/AppTab.vue +3 -10
  28. package/samples/MetroWidgetDemos/PingPong/{Item.vue → TabItem.vue} +2 -10
  29. package/samples/MetroWidgetDemos/PingPong/ViewSwiper.vue +2 -2
  30. package/samples/MetroWidgetDemos/Simple/AbsoluteTemplate.vue +2 -2
  31. package/samples/MetroWidgetDemos/Simple/App.vue +2 -2
  32. package/samples/MetroWidgetDemos/Simple/RelativeTemplate.vue +4 -4
  33. package/samples/MetroWidgetDemos/data.js +2 -1
  34. package/samples/Preload/App.vue +16 -11
  35. package/samples/ScaleDownNeon/App.vue +107 -0
  36. package/samples/TextBox/App.vue +7 -81
  37. package/samples/TextBox/RenderCenter.vue +40 -16
  38. package/samples/TextBox/RenderLeft.vue +48 -19
  39. package/samples/TextBox/RenderOneLine.vue +30 -49
  40. package/samples/TextBox/RenderRight.vue +40 -16
  41. package/samples/TextShadowDemo/App.vue +11 -17
  42. package/samples/TextureAnimation/App2.vue +111 -0
  43. package/samples/TextureAnimation/assets/blackWhiteGrid.png +0 -0
  44. package/samples/TextureAnimation/assets/light.png +0 -0
  45. package/samples/TextureAnimation/assets/light2.png +0 -0
  46. package/samples/TextureAnimation/assets/mask.png +0 -0
  47. package/samples/TextureSize/App.vue +3 -3
  48. package/samples/VisibleSensorDemo/App.vue +92 -25
  49. package/utils/JsViewEngineWidget/MetroWidget/Const.js +11 -0
  50. package/utils/JsViewEngineWidget/MetroWidget/MetroWidget.vue +188 -80
  51. package/utils/JsViewEngineWidget/TemplateParser.js +89 -32
  52. package/utils/JsViewEngineWidget/WidgetCommon.js +3 -4
  53. package/utils/JsViewEngineWidget/index.js +3 -2
  54. package/utils/JsViewPlugin/JsvPlayer/JsvMedia.js +95 -12
  55. package/utils/JsViewPlugin/JsvPlayer/JsvPlayer.vue +25 -3
  56. package/utils/JsViewPlugin/JsvPlayer/index.js +22 -1
  57. package/utils/JsViewPlugin/JsvPlayer/version.js +4 -4
  58. package/utils/JsViewVueTools/JsvImpactTracer.js +113 -0
  59. package/utils/JsViewVueTools/index.js +2 -1
  60. package/utils/JsViewVueWidget/BrowserDebugWidget/BrowserPreload.vue +11 -1
  61. package/utils/JsViewVueWidget/BrowserDebugWidget/BrowserTextureAnim.vue +203 -14
  62. package/utils/JsViewVueWidget/JsvActorMove/JsvActorMove.vue +2 -2
  63. package/utils/JsViewVueWidget/JsvInput/Cursor.vue +4 -2
  64. package/utils/JsViewVueWidget/JsvInput/JsvInput.vue +13 -12
  65. package/utils/JsViewVueWidget/JsvMarquee.vue +178 -205
  66. package/utils/JsViewVueWidget/JsvNativeSharedDiv.vue +35 -27
  67. package/utils/JsViewVueWidget/JsvNinePatch.vue +1 -2
  68. package/utils/JsViewVueWidget/JsvPreload/JsvPreload.vue +37 -41
  69. package/utils/JsViewVueWidget/JsvSpriteAnim/JsvSpriteAnim.vue +282 -285
  70. package/utils/JsViewVueWidget/JsvSwiper/JsvSwiper.vue +18 -2
  71. package/utils/JsViewVueWidget/JsvSwiper3D/JsvSwiper.vue +22 -2
  72. package/utils/JsViewVueWidget/JsvTextBox.vue +35 -72
  73. package/utils/JsViewVueWidget/JsvTextureAnim/JsvTextureAnim.vue +123 -46
  74. package/utils/JsViewVueWidget/JsvTextureAnim/index.js +9 -5
  75. package/utils/JsViewVueWidget/JsvTouchContainer.vue +3 -4
  76. package/utils/JsViewVueWidget/JsvVideo.vue +9 -12
  77. package/utils/JsViewVueWidget/index.js +2 -2
  78. package/utils/JsViewVueWidget/utils/index.js +8 -0
  79. package/utils/JsViewVueWidget/utils/text.js +19 -0
  80. package/utils/JsViewEngineWidget/MetroPage.js +0 -2128
  81. package/utils/JsViewEngineWidget/SimpleWidget/ContentView.vue +0 -51
  82. package/utils/JsViewEngineWidget/SimpleWidget/Dispatcher.js +0 -19
  83. package/utils/JsViewEngineWidget/SimpleWidget/DivWrapper.vue +0 -53
  84. package/utils/JsViewEngineWidget/SimpleWidget/ItemView.vue +0 -142
  85. package/utils/JsViewEngineWidget/SimpleWidget/RootView.vue +0 -140
  86. package/utils/JsViewEngineWidget/SimpleWidget/SimpleWidget.vue +0 -1629
@@ -0,0 +1,435 @@
1
+ <!--
2
+ * @Author: ChenChanghua
3
+ * @Date: 2022-08-31 10:17:26
4
+ * @LastEditors: ChenChanghua
5
+ * @LastEditTime: 2022-08-31 11:17:20
6
+ * @Description: file content
7
+ -->
8
+ <script setup>
9
+ import {
10
+ JsvActorMoveControl,
11
+ JsvActorMove,
12
+ createImpactTracer,
13
+ createImpactCallback,
14
+ createImpactAutoFroze,
15
+ } from "jsview";
16
+ import { ref, computed, onMounted, onBeforeUnmount } from "vue";
17
+ import { useRouter } from "vue-router";
18
+ const router = useRouter();
19
+ const CONST_BOARD_LEFT = 0;
20
+ const CONST_BOARD_RIGHT = 1;
21
+ const CONST_BOARD_MID = 2;
22
+
23
+ const CONST_BOX_WIDTH = 30;
24
+ const CONST_BOX_HEIGHT = 30;
25
+
26
+ const horizontalControl = new JsvActorMoveControl();
27
+ const verticalControl = new JsvActorMoveControl();
28
+ const boxLeft = ref(null);
29
+ const boxMid = ref(null);
30
+ const boxRight = ref(null);
31
+ const actorVertical = { current: null };
32
+ const actorHorizontal = { current: null };
33
+ const actor = ref(null);
34
+
35
+ let viewsAutoFroze = null;
36
+ let sensorList = [];
37
+ let onBoard = CONST_BOARD_LEFT;
38
+ let keyPressed = false;
39
+ const actorState = {
40
+ jumping: false,
41
+ hMoving: false,
42
+ };
43
+ const showPrecisionGuild = ref(true);
44
+ const direction = ref(1);
45
+ const bodyState = ref(0);
46
+ const isJsView = Boolean(window.JsView);
47
+
48
+ const actorColor = computed(() => {
49
+ switch (bodyState.value) {
50
+ case 0: // 静止
51
+ return "#FF00FF";
52
+ case 1: // 跳起
53
+ return "#FFFF00";
54
+ case 2: // 落下
55
+ return "#00FFFF";
56
+ default:
57
+ return "#FFFFFF";
58
+ }
59
+ });
60
+
61
+ const onImpact = (impact_type) => {
62
+ // 根据碰撞层来调整滑块的状态(接触板信息)
63
+ console.log(`On impacted type=${impact_type}`);
64
+ bodyState.value = 0;
65
+ onBoard = impact_type;
66
+ switch (impact_type) {
67
+ case CONST_BOARD_MID:
68
+ verticalControl.jumpTo(0, -200); // jumpTo处理微小穿模的复位,-200为中间层和起始位置的高度差
69
+ horizontalControl.pause();
70
+ break;
71
+ case CONST_BOARD_LEFT:
72
+ verticalControl.jumpTo(0, 0);
73
+ horizontalControl.pause();
74
+ direction.value = 1;
75
+ break;
76
+ case CONST_BOARD_RIGHT:
77
+ verticalControl.jumpTo(0, 0);
78
+ horizontalControl.pause();
79
+ direction.value = -1; // 反向
80
+ break;
81
+ default:
82
+ break;
83
+ }
84
+ actorState.jumping = false;
85
+ };
86
+
87
+ const onLanding = () => {
88
+ // 滑块未与左中右任何一个板发生碰撞,落在了地板的时候
89
+ console.log("On landing");
90
+ bodyState.value = 0;
91
+ actorState.jumping = false;
92
+ reset();
93
+ };
94
+
95
+ const reset = () => {
96
+ console.log("On reset");
97
+ // 将两个运动都停止后再进行jumpTo,以保证两个jumpTo动作在同一帧完成
98
+ verticalControl.pause(() => {
99
+ horizontalControl.pause(() => {
100
+ verticalControl.jumpTo(0, 0);
101
+ horizontalControl.jumpTo(0, 0);
102
+ onBoard = CONST_BOARD_LEFT;
103
+ showPrecisionGuild.value = true;
104
+ direction.value = 1;
105
+ });
106
+ });
107
+ };
108
+
109
+ const onKeyDown = (ev) => {
110
+ if (ev.keyCode == 8 || ev.keyCode == 27 || ev.keyCode == 10000) {
111
+ router?.go(-1); // 有router时,是从DemoHomepage进入,回退
112
+ }
113
+ if (actorState.jumping) {
114
+ // 跳跃中,键盘锁定
115
+ return true;
116
+ }
117
+
118
+ if (keyPressed) {
119
+ // KeyPress控制按键连点
120
+ return true;
121
+ }
122
+
123
+ // 控制按键按下时,键盘锁定
124
+ keyPressed = true;
125
+
126
+ // 滑块位置可能发生变更,所以消除动画精度测试的描素文字
127
+ if (showPrecisionGuild.value) {
128
+ showPrecisionGuild.value = false;
129
+ }
130
+
131
+ if (ev.keyCode === 13) {
132
+ // 滑块跳跃(纵向和横向的配置值都是计算过的,为了进行第一跳的精度测试)
133
+ actorState.jumping = true;
134
+ // 垂直方向抛物运动
135
+ bodyState.value = 1;
136
+ verticalControl.throwAlongY(
137
+ -1000,
138
+ 2450,
139
+ { type: "catch", position: 100, direction: 1 },
140
+ () => {
141
+ onLanding();
142
+ }, // 未碰撞落地时,对滑块位置进行重置
143
+ () => {
144
+ bodyState.value = 2;
145
+ } // 调整成落下状态
146
+ );
147
+ // 水平方向,按照direction的值,移动到屏幕两端
148
+ if (direction.value > 0) {
149
+ horizontalControl.moveToX(1200 - CONST_BOX_WIDTH, 400, null);
150
+ } else {
151
+ horizontalControl.moveToX(0, 400, null);
152
+ }
153
+ } else if (ev.keyCode === 37) {
154
+ // 滑块向左移动
155
+ actorState.hMoving = true;
156
+ // 分三个区域设定移动范围
157
+ let target_x = 0;
158
+ if (onBoard === CONST_BOARD_LEFT) {
159
+ target_x = 0;
160
+ } else if (onBoard === CONST_BOARD_MID) {
161
+ target_x = 500;
162
+ } else if (onBoard === CONST_BOARD_RIGHT) {
163
+ target_x = 800;
164
+ }
165
+ horizontalControl.moveToX(target_x, 300, null);
166
+ } else if (ev.keyCode === 39) {
167
+ // 滑块向右移动
168
+ actorState.hMoving = true;
169
+ // 分三个区域设定移动范围
170
+ let target_x = 0;
171
+ if (onBoard === CONST_BOARD_LEFT) {
172
+ target_x = 396 - CONST_BOX_WIDTH;
173
+ } else if (onBoard === CONST_BOARD_MID) {
174
+ target_x = 699 - CONST_BOX_WIDTH;
175
+ } else if (onBoard === CONST_BOARD_RIGHT) {
176
+ target_x = 1199 - CONST_BOX_WIDTH;
177
+ }
178
+ horizontalControl.moveToX(target_x, 350, null);
179
+ }
180
+ return true;
181
+ };
182
+
183
+ const onKeyUp = () => {
184
+ keyPressed = false;
185
+
186
+ if (actorState.hMoving) {
187
+ // 停止用户通过左右键发起的水平移动
188
+ horizontalControl.pause(null);
189
+ actorState.hMoving = false;
190
+ }
191
+ };
192
+
193
+ onMounted(() => {
194
+ /* 关联碰撞体处理要在didMount中进行 */
195
+
196
+ /* 将碰撞发生后要停止动画的元素打包 */
197
+ viewsAutoFroze = createImpactAutoFroze(
198
+ [actorVertical.current, actorHorizontal.current],
199
+ null
200
+ ); // 此句柄最好保留,未来可以通过此句柄统一进行views list更新
201
+
202
+ /* 构建左边碰撞区 */
203
+ sensorList.push(
204
+ createImpactTracer(
205
+ actor.value,
206
+ boxLeft.value,
207
+ createImpactCallback(() => {
208
+ onImpact(CONST_BOARD_LEFT);
209
+ }, null),
210
+ viewsAutoFroze
211
+ )
212
+ );
213
+
214
+ /* 构建中间碰撞区 */
215
+ sensorList.push(
216
+ createImpactTracer(
217
+ actor.value,
218
+ boxMid.value,
219
+ createImpactCallback(() => {
220
+ onImpact(CONST_BOARD_MID);
221
+ }, null),
222
+ viewsAutoFroze
223
+ )
224
+ );
225
+
226
+ /* 构建右边碰撞区 */
227
+ sensorList.push(
228
+ createImpactTracer(
229
+ actor.value,
230
+ boxRight.value,
231
+ createImpactCallback(() => {
232
+ onImpact(CONST_BOARD_RIGHT);
233
+ }, null),
234
+ viewsAutoFroze
235
+ )
236
+ );
237
+
238
+ reset();
239
+ });
240
+
241
+ onBeforeUnmount(() => {
242
+ /* 重要! 退出后应该释放所有碰撞监听者 */
243
+ for (const sensor of sensorList) {
244
+ sensor.Recycle();
245
+ }
246
+ });
247
+ </script>
248
+
249
+ <template>
250
+ <jsv-focus-block
251
+ autoFocus
252
+ :onAction="{
253
+ onKeyDown,
254
+ onKeyUp,
255
+ }"
256
+ :style="{ width: 1280, height: 720, backgroundColor: '#000000' }"
257
+ >
258
+ <div
259
+ v-if="isJsView"
260
+ :style="{
261
+ textAlign: 'center',
262
+ fontSize: '30px',
263
+ lineHeight: '50px',
264
+ color: '#ffffff',
265
+ left: 100,
266
+ top: 20,
267
+ width: 1280 - 200,
268
+ height: 50,
269
+ backgroundColor: 'rgba(27,38,151,0.8)',
270
+ }"
271
+ >
272
+ JsView环境下不会穿透模型
273
+ </div>
274
+
275
+ <div
276
+ key="bottomWall"
277
+ :style="{
278
+ top: 620,
279
+ left: 40,
280
+ width: 1200,
281
+ height: 5,
282
+ backgroundColor: '#F0FFF0',
283
+ }"
284
+ />
285
+
286
+ <div
287
+ key="leftFloor"
288
+ :style="{
289
+ top: 520,
290
+ left: 40,
291
+ width: 397,
292
+ height: 5,
293
+ backgroundColor: '#F0F000',
294
+ }"
295
+ />
296
+
297
+ <!-- 碰撞体的高度要比每帧移动距离大,因为碰撞判断是每帧内进行判断,并不连续,距离太小可能穿模 -->
298
+
299
+ <div
300
+ key="leftFloorImp"
301
+ ref="boxLeft"
302
+ :style="{
303
+ top: 520,
304
+ left: 40,
305
+ width: 397,
306
+ height: 15,
307
+ backgroundColor: 'rgba(255,255,255,0.2)',
308
+ }"
309
+ />
310
+
311
+ <div
312
+ key="midFloor"
313
+ :style="{
314
+ top: 320,
315
+ left: 540,
316
+ width: 200,
317
+ height: 5,
318
+ backgroundColor: '#F0F000',
319
+ }"
320
+ />
321
+ <div
322
+ key="midFloorImp"
323
+ ref="boxMid"
324
+ :style="{
325
+ top: 320,
326
+ left: 540,
327
+ width: 200,
328
+ height: 15,
329
+ backgroundColor: 'rgba(0,0,0,0)',
330
+ }"
331
+ />
332
+
333
+ <div
334
+ key="rightFloor"
335
+ :style="{
336
+ top: 520,
337
+ left: 840,
338
+ width: 400,
339
+ height: 5,
340
+ backgroundColor: '#F0F000',
341
+ }"
342
+ />
343
+ <div
344
+ key="rightFloorImp"
345
+ ref="boxRight"
346
+ :style="{
347
+ top: 520,
348
+ left: 820,
349
+ width: 400,
350
+ height: 15,
351
+ backgroundColor: 'rgba(0,0,0,0)',
352
+ }"
353
+ />
354
+
355
+ <div
356
+ v-if="showPrecisionGuild"
357
+ key="PrecisionGuideText"
358
+ class="text"
359
+ :style="{ top: 528, left: 40, width: 405, height: 40 }"
360
+ >
361
+ JSV下,立刻起跳会精确到边缘
362
+ </div>
363
+
364
+ <div
365
+ key="GuideText1"
366
+ class="text"
367
+ :style="{ top: 625, left: 370, width: 540, height: 40 }"
368
+ >
369
+ 左右键调整跳跃起点,按OK键进行跳跃
370
+ </div>
371
+ <div
372
+ key="DirectText"
373
+ class="text"
374
+ :style="{ top: 150, left: 425, width: 430, height: 40 }"
375
+ >
376
+ {{ `当前方向:${direction > 0 ? "->" : "<-"}` }}
377
+ </div>
378
+
379
+ <div key="actor" :style="{ top: 520 - CONST_BOX_HEIGHT - 2, left: 40 }">
380
+ <jsv-actor-move
381
+ key="horizontal"
382
+ :refDefine="actorHorizontal"
383
+ :control="horizontalControl"
384
+ >
385
+ <jsv-actor-move
386
+ key="vertical"
387
+ :refDefine="actorVertical"
388
+ :control="verticalControl"
389
+ >
390
+ <div
391
+ ref="actor"
392
+ :style="{
393
+ backgroundColor: actorColor,
394
+ width: CONST_BOX_WIDTH,
395
+ height: CONST_BOX_HEIGHT,
396
+ }"
397
+ ></div>
398
+ </jsv-actor-move>
399
+ </jsv-actor-move>
400
+ </div>
401
+
402
+ <!-- 一个无限动画元素,来测试卡顿 -->
403
+ <div
404
+ :style="{
405
+ top: 100,
406
+ left: 50,
407
+ height: 150,
408
+ width: 150,
409
+ backgroundColor: '#334455',
410
+ animation: 'impact-stop-anim-rotate 1s infinite linear',
411
+ }"
412
+ />
413
+ </jsv-focus-block>
414
+ </template>
415
+
416
+ <style scoped>
417
+ @keyframes impact-stop-anim-rotate {
418
+ from {
419
+ transform: rotate3d(0, 0, 1, 270deg);
420
+ }
421
+ to {
422
+ transform: rotate3d(0, 0, 1, 0deg);
423
+ }
424
+ }
425
+
426
+ .text {
427
+ font-size: 30px;
428
+ color: #73665c;
429
+ line-height: 40px;
430
+ overflow: hidden;
431
+ white-space: nowrap;
432
+ text-overflow: ellipsis;
433
+ text-align: center;
434
+ }
435
+ </style>
@@ -2,11 +2,11 @@
2
2
  * @Author: ChenChanghua
3
3
  * @Date: 2022-01-20 16:09:31
4
4
  * @LastEditors: ChenChanghua
5
- * @LastEditTime: 2022-07-08 13:37:44
5
+ * @LastEditTime: 2022-09-01 17:34:30
6
6
  * @Description: file content
7
7
  -->
8
8
  <script>
9
- import { InputType, EdgeDirection } from "jsview";
9
+ import { InputType, EdgeDirection, useFocusHub } from "jsview";
10
10
  import InputPanel from "./InputPanel.vue";
11
11
 
12
12
  export default {
@@ -17,6 +17,7 @@ export default {
17
17
  return {
18
18
  name: "/input",
19
19
  InputType,
20
+ focusHub: useFocusHub(),
20
21
  };
21
22
  },
22
23
  methods: {
@@ -27,33 +28,23 @@ export default {
27
28
  return true;
28
29
  },
29
30
  _onFocus() {
30
- this.$refs.focusNode
31
- .findBlockByName(this.name + "/normal")
32
- .requestFocus();
31
+ this.focusHub.setFocus(this.name + "/normal");
33
32
  },
34
33
  _panel1OnEdge(edgeInfo) {
35
34
  if (edgeInfo.direction == EdgeDirection.right) {
36
- this.$refs.focusNode
37
- .findBlockByName(this.name + "/password")
38
- .requestFocus();
35
+ this.focusHub.setFocus(this.name + "/password");
39
36
  }
40
37
  },
41
38
  _panel2OnEdge(edgeInfo) {
42
39
  if (edgeInfo.direction == EdgeDirection.left) {
43
- this.$refs.focusNode
44
- .findBlockByName(this.name + "/normal")
45
- .requestFocus();
40
+ this.focusHub.setFocus(this.name + "/normal");
46
41
  } else if (edgeInfo.direction == EdgeDirection.right) {
47
- this.$refs.focusNode
48
- .findBlockByName(this.name + "/number")
49
- .requestFocus();
42
+ this.focusHub.setFocus(this.name + "/number");
50
43
  }
51
44
  },
52
45
  _panel3OnEdge(edgeInfo) {
53
46
  if (edgeInfo.direction == EdgeDirection.left) {
54
- this.$refs.focusNode
55
- .findBlockByName(this.name + "/password")
56
- .requestFocus();
47
+ this.focusHub.setFocus(this.name + "/password");
57
48
  }
58
49
  },
59
50
  },
@@ -2,13 +2,17 @@
2
2
  * @Author: ChenChanghua
3
3
  * @Date: 2022-01-25 10:33:07
4
4
  * @LastEditors: ChenChanghua
5
- * @LastEditTime: 2022-07-08 13:38:14
5
+ * @LastEditTime: 2022-09-02 13:44:41
6
6
  * @Description: file content
7
7
  -->
8
8
  <script>
9
9
  import FullKeyboard from "./FullKeyboard.vue";
10
- import { EdgeDirection, JsvInput } from "jsview";
10
+ import { EdgeDirection, JsvInput, useFocusHub } from "jsview";
11
11
  import { ref } from "vue";
12
+
13
+ const blurColor = "#AAAAAA";
14
+ const focusColor = "#FFFF00";
15
+
12
16
  export default {
13
17
  components: {
14
18
  FullKeyboard,
@@ -24,17 +28,20 @@ export default {
24
28
  setup() {
25
29
  return {
26
30
  showCursor: ref(false),
31
+ focusHub: useFocusHub(),
32
+ cursorColor: ref(blurColor),
27
33
  };
28
34
  },
29
35
  methods: {
30
36
  _onFocus() {
31
37
  this.showCursor = true;
32
- this.$refs.focusNode
33
- .findBlockByName(`${this.name}/keyboard`)
34
- .requestFocus();
38
+ this.cursorColor = blurColor;
39
+ this.focusHub.setFocus(`${this.name}/keyboard`);
35
40
  },
36
41
  _onBlur() {
42
+ console.log("testtest onblur");
37
43
  this.showCursor = false;
44
+ this.cursorColor = blurColor;
38
45
  },
39
46
  _keyboardOnClick(item) {
40
47
  const char = item.content;
@@ -48,9 +55,8 @@ export default {
48
55
  },
49
56
  _keyboardOnEdge(edgeInfo) {
50
57
  if (edgeInfo.direction === EdgeDirection.top) {
51
- this.$refs.focusNode
52
- .findBlockByName(`${this.name}/etext`)
53
- .requestFocus();
58
+ this.focusHub.setFocus(`${this.name}/etext`);
59
+ this.cursorColor = focusColor;
54
60
  } else {
55
61
  this.onEdge?.(edgeInfo);
56
62
  }
@@ -63,9 +69,8 @@ export default {
63
69
  },
64
70
  _inputOnEdge(edgeInfo) {
65
71
  if (edgeInfo.direction === EdgeDirection.bottom) {
66
- this.$refs.focusNode
67
- .findBlockByName(`${this.name}/keyboard`)
68
- .requestFocus();
72
+ this.focusHub.setFocus(`${this.name}/keyboard`);
73
+ this.cursorColor = blurColor;
69
74
  } else {
70
75
  this.onEdge?.(edgeInfo);
71
76
  }
@@ -81,6 +86,7 @@ export default {
81
86
  ref="focusNode"
82
87
  :onAction="{
83
88
  onFocus: _onFocus,
89
+ onBlur: _onBlur,
84
90
  }"
85
91
  >
86
92
  <div
@@ -111,6 +117,7 @@ export default {
111
117
  :cursorWidth="2"
112
118
  :onTextChange="_onTextChange"
113
119
  :onTextOverflow="_onTextOverflow"
120
+ :cursorColor="cursorColor"
114
121
  />
115
122
 
116
123
  <div :style="{ top: 100 }">