From e491cdb48129752324c4e3764f99bd9203c56dec Mon Sep 17 00:00:00 2001
From: lgq <1015864684@qq.com>
Date: 星期二, 31 三月 2026 09:48:44 +0800
Subject: [PATCH] 1.新增VF205门禁机代码
---
vf205_access/src/view/pinyin/pinyin.js | 1049 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 1,049 insertions(+), 0 deletions(-)
diff --git a/vf205_access/src/view/pinyin/pinyin.js b/vf205_access/src/view/pinyin/pinyin.js
new file mode 100644
index 0000000..4a2003d
--- /dev/null
+++ b/vf205_access/src/view/pinyin/pinyin.js
@@ -0,0 +1,1049 @@
+import dxui from '../../../dxmodules/dxUi.js'
+import dict from './dict.js'
+const pinyin = {}
+
+// 閿洏澶у皬
+let width = 800
+let height = 400
+// 鏄惁閿佸畾閿洏
+let isLock = false
+// 鏄惁鏀寔鎷奸煶杈撳叆
+let enablePinyin = true
+// 鍒濆鍖栧鍣�
+pinyin.init = function (w, h) {
+ width = w
+ height = h
+
+ // 鍙厑璁稿垵濮嬪寲涓�娆�
+ if (pinyin.inited) {
+ return
+ }
+ pinyin.inited = true
+ // 鍏ㄥ眬瀛椾綋
+ pinyin.font24 = dxui.Font.build('/app/code/resource/font/AlibabaPuHuiTi-2-65-Medium.ttf', 24, dxui.Utils.FONT_STYLE.NORMAL)
+ let container = dxui.View.build('container', dxui.Utils.LAYER.TOP)
+ pinyin.container = container
+ clearStyle(container)
+ container.obj.lvObjAddFlag(dxui.Utils.ENUM.LV_OBJ_FLAG_OVERFLOW_VISIBLE)
+ container.setSize(width, height)
+ container.align(dxui.Utils.ALIGN.BOTTOM_MID, 0, 0)
+ container.textFont(pinyin.font24)
+ // 瀹瑰櫒鍒濆鍖�
+ container.bgOpa(0)
+ container.update()
+ container.hide()
+ // 鍒涘缓涓夌閿洏妯″紡
+ pinyin.englishPanel = createEnglish()
+ pinyin.pinyinPanel = createPinyin()
+ pinyin.numPanel = createNum()
+ pinyin.symbolPanel = createSymbol()
+}
+pinyin.getSize = function () {
+ return { width: width, height: height }
+}
+/**
+ * 鏄剧ず閿洏锛岄渶瑕佸厛鍒濆鍖�
+ * @param {number} mode 閿洏妯″紡锛�0锛氳嫳鏂囬敭鐩橈紝1锛氭嫾闊抽敭鐩橈紝2锛氭暟瀛楅敭鐩橈紝3锛氱鍙烽敭鐩�
+ * @param {function} cb 鎸夐敭鍐呭鍥炶皟
+ */
+pinyin.show = function (mode, cb) {
+ if (![0, 1, 2, 3].includes(mode)) {
+ return
+ }
+ this.unlock()
+ this.hide()
+ // 鎸夐敭鍐呭鍥炶皟
+ pinyin.cb = cb
+ pinyin.container.show()
+ pinyin.container.moveForeground()
+ switch (mode) {
+ case 0:
+ pinyin.englishPanel.show()
+ break;
+ case 1:
+ pinyin.pinyinPanel.show()
+ break;
+ case 2:
+ pinyin.numPanel.show()
+ break;
+ case 3:
+ pinyin.symbolPanel.show()
+ break;
+ default:
+ break;
+ }
+}
+// 鑾峰彇褰撳墠閿洏妯″紡
+pinyin.getMode = function () {
+ if (!pinyin.englishPanel.isHide()) {
+ return 0
+ } else if (!pinyin.pinyinPanel.isHide()) {
+ return 1
+ } else if (!pinyin.numPanel.isHide()) {
+ return 2
+ } else if (!pinyin.symbolPanel.isHide()) {
+ return 3
+ } else {
+ return 0
+ }
+}
+// 闅愯棌閿洏
+pinyin.hide = function () {
+ pinyin.englishPanel.hide()
+ pinyin.pinyinPanel.hide()
+ pinyin.numPanel.hide()
+ pinyin.symbolPanel.hide()
+ pinyin.container.hide()
+ if (pinyin.callback) {
+ pinyin.callback()
+ pinyin.callback = null
+ }
+}
+// 闅愯棌鍥炶皟锛屽崟娆℃湁鏁�
+pinyin.hideCb = function (cb) {
+ pinyin.callback = cb
+}
+// 閿佸畾閿洏锛屼笉鍏佽鍒囨崲妯″紡
+pinyin.lock = function () {
+ isLock = true
+}
+// 瑙i櫎閿佸畾閿洏
+pinyin.unlock = function () {
+ isLock = false
+}
+pinyin.pinyinSupport = function (bool) {
+ enablePinyin = bool
+}
+
+// 鑻辨枃閿洏
+function createEnglish() {
+ let englishPanel = dxui.View.build(pinyin.container.id + 'englishPanel', pinyin.container)
+ clearStyle(englishPanel)
+ englishPanel.setSize(pinyin.container.width(), pinyin.container.height())
+ englishPanel.update()
+ // 鍒涘缓澶у皬鍐欑殑鑻辨枃閿洏
+ function createKeyboard(capital) {
+ let englishKeyboard = dxui.Buttons.build(englishPanel.id + 'englishKeyboard' + (capital ? "Big" : "Small"), englishPanel)
+ clearStyle(englishKeyboard)
+ englishKeyboard.obj.lvObjSetStylePadGap(10, dxui.Utils.ENUM._LV_STYLE_STATE_CMP_SAME)
+ englishKeyboard.padAll(10)
+ englishKeyboard.bgColor(0xffffff, dxui.Utils.STYLE_PART.ITEMS)
+ englishKeyboard.bgColor(0xe6e6e6)
+ englishKeyboard.setSize(englishPanel.width(), englishPanel.height())
+ englishKeyboard.align(dxui.Utils.ALIGN.BOTTOM_MID, 0, 0)
+ if (capital) {
+ englishKeyboard.data([
+ "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "\n",
+ " ", "A", "S", "D", "F", "G", "H", "J", "K", "L", " ", "\n",
+ "鈫�", "Z", "X", "C", "V", "B", "N", "M", " ", "\n",
+ "!?#", "123", ",", " ", ".", "EN", " ",
+ ""])
+ } else {
+ englishKeyboard.data([
+ "q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "\n",
+ " ", "a", "s", "d", "f", "g", "h", "j", "k", "l", " ", "\n",
+ "鈫�", "z", "x", "c", "v", "b", "n", "m", " ", "\n",
+ "!?#", "123", ",", " ", ".", "EN", " ",
+ ""])
+ }
+ // 璁剧疆鎸夐挳瀹藉害
+ englishKeyboard.setBtnWidth(10, 1)
+ for (let i = 11; i < 20; i++) {
+ englishKeyboard.setBtnWidth(i, 2)
+ }
+ englishKeyboard.setBtnWidth(20, 1)
+ englishKeyboard.setBtnWidth(21, 3)
+ for (let i = 22; i < 29; i++) {
+ englishKeyboard.setBtnWidth(i, 2)
+ }
+ englishKeyboard.setBtnWidth(29, 3)
+ englishKeyboard.obj.addEventCb((e) => {
+ let dsc = e.lvEventGetDrawPartDsc()
+ if (dsc.class_p == englishKeyboard.obj.ClassP && dsc.type == dxui.Utils.ENUM.LV_BTNMATRIX_DRAW_PART_BTN) {
+ // 闅愯棌鏃犵敤鎸夐挳
+ if (dsc.id == 10 || dsc.id == 20) {
+ dxui.Utils.GG.NativeDraw.lvDrawRectReset(dsc.rect_dsc, { bg_opa: 0, shadow_opa: 0 })
+ }
+ // 鍔犳繁涓�浜涘姛鑳芥寜閽�
+ if (dsc.id == 21 || dsc.id == 29 || dsc.id == 30 || dsc.id == 31 || dsc.id == 35) {
+ if (englishKeyboard.obj.lvBtnmatrixGetSelectedBtn() == dsc.id && e.lvEventGetTarget().hasState(dxui.Utils.ENUM.LV_STATE_PRESSED)) {
+ dxui.Utils.GG.NativeDraw.lvDrawRectReset(dsc.rect_dsc, { bg_color: 0xcdcdcd })
+ } else {
+ dxui.Utils.GG.NativeDraw.lvDrawRectReset(dsc.rect_dsc, { bg_color: 0xdbdbdb })
+ }
+ }
+ // 鍥炶溅鎸夐挳钃濊壊
+ if (dsc.id == 36) {
+ if (englishKeyboard.obj.lvBtnmatrixGetSelectedBtn() == dsc.id && e.lvEventGetTarget().hasState(dxui.Utils.ENUM.LV_STATE_PRESSED)) {
+ dxui.Utils.GG.NativeDraw.lvDrawRectReset(dsc.rect_dsc, { bg_color: 0x0C6CE4 })
+ } else {
+ dxui.Utils.GG.NativeDraw.lvDrawRectReset(dsc.rect_dsc, { bg_color: 0x0C78FE })
+ }
+ }
+ }
+ }, dxui.Utils.ENUM.LV_EVENT_DRAW_PART_BEGIN)
+ englishKeyboard.obj.addEventCb((e) => {
+ let dsc = e.lvEventGetDrawPartDsc()
+ if (dsc.class_p == englishKeyboard.obj.ClassP && dsc.type == dxui.Utils.ENUM.LV_BTNMATRIX_DRAW_PART_BTN) {
+ // 鍒犻櫎鎸夐挳鍥炬娣诲姞
+ if (dsc.id == 29) {
+ let src = '/app/code/resource/image/backspace.png'
+ // 鑾峰彇鍥剧墖淇℃伅
+ let header = dxui.Utils.GG.NativeDraw.lvImgDecoderGetInfo(src)
+ // 瀹氫箟涓�鍧楀尯鍩燂紝灞呬腑鏄剧ず锛屾敞鎰忥細灏哄杞琣rea闇�瑕�-1锛宎rea杞昂瀵搁渶瑕�+1
+ let x1 = dsc.draw_area.x1 + (dsc.draw_area.x2 - dsc.draw_area.x1 + 1 - header.w) / 2;
+ let y1 = dsc.draw_area.y1 + (dsc.draw_area.y2 - dsc.draw_area.y1 + 1 - header.h) / 2;
+ let x2 = x1 + header.w - 1;
+ let y2 = y1 + header.h - 1;
+ let area = dxui.Utils.GG.NativeArea.lvAreaSet(x1, y1, x2, y2)
+ // 缁樺埗鍥剧墖淇℃伅
+ let img_draw_dsc = dxui.Utils.GG.NativeDraw.lvDrawImgDscInit()
+ // 缁樺埗鍥剧墖
+ dxui.Utils.GG.NativeDraw.lvDrawImg(dsc.dsc, img_draw_dsc, area, src)
+ }
+ // 鍥炶溅鎸夐挳鍥炬娣诲姞
+ if (dsc.id == 36) {
+ let src = '/app/code/resource/image/enter.png'
+ // 鑾峰彇鍥剧墖淇℃伅
+ let header = dxui.Utils.GG.NativeDraw.lvImgDecoderGetInfo(src)
+ // 瀹氫箟涓�鍧楀尯鍩燂紝灞呬腑鏄剧ず锛屾敞鎰忥細灏哄杞琣rea闇�瑕�-1锛宎rea杞昂瀵搁渶瑕�+1
+ let x1 = dsc.draw_area.x1 + (dsc.draw_area.x2 - dsc.draw_area.x1 + 1 - header.w) / 2;
+ let y1 = dsc.draw_area.y1 + (dsc.draw_area.y2 - dsc.draw_area.y1 + 1 - header.h) / 2;
+ let x2 = x1 + header.w - 1;
+ let y2 = y1 + header.h - 1;
+ let area = dxui.Utils.GG.NativeArea.lvAreaSet(x1, y1, x2, y2)
+ // 缁樺埗鍥剧墖淇℃伅
+ let img_draw_dsc = dxui.Utils.GG.NativeDraw.lvDrawImgDscInit()
+ // 缁樺埗鍥剧墖
+ dxui.Utils.GG.NativeDraw.lvDrawImg(dsc.dsc, img_draw_dsc, area, src)
+ }
+ // 绌烘牸鎸夐挳鍥炬娣诲姞
+ if (dsc.id == 33) {
+ let src = '/app/code/resource/image/space.png'
+ // 鑾峰彇鍥剧墖淇℃伅
+ let header = dxui.Utils.GG.NativeDraw.lvImgDecoderGetInfo(src)
+ // 瀹氫箟涓�鍧楀尯鍩燂紝灞呬腑鏄剧ず锛屾敞鎰忥細灏哄杞琣rea闇�瑕�-1锛宎rea杞昂瀵搁渶瑕�+1
+ let x1 = dsc.draw_area.x1 + (dsc.draw_area.x2 - dsc.draw_area.x1 + 1 - header.w) / 2;
+ let y1 = dsc.draw_area.y1 + (dsc.draw_area.y2 - dsc.draw_area.y1 + 1 - header.h) / 2;
+ let x2 = x1 + header.w - 1;
+ let y2 = y1 + header.h - 1;
+ y1 += 10
+ y2 += 10
+ let area = dxui.Utils.GG.NativeArea.lvAreaSet(x1, y1, x2, y2)
+ // 缁樺埗鍥剧墖淇℃伅
+ let img_draw_dsc = dxui.Utils.GG.NativeDraw.lvDrawImgDscInit()
+ // 缁樺埗鍥剧墖
+ dxui.Utils.GG.NativeDraw.lvDrawImg(dsc.dsc, img_draw_dsc, area, src)
+ }
+ }
+ }, dxui.Utils.ENUM.LV_EVENT_DRAW_PART_END)
+ englishKeyboard.on(dxui.Utils.ENUM.LV_EVENT_LONG_PRESSED_REPEAT, () => {
+ let clickBtn = englishKeyboard.clickedButton()
+ let id = clickBtn.id
+ switch (id) {
+ case 29:
+ // 閫�鏍�
+ pinyin.cb({ cmd: "backspace" })
+ break;
+ }
+ })
+ englishKeyboard.on(dxui.Utils.ENUM.LV_EVENT_PRESSED, () => {
+ let clickBtn = englishKeyboard.clickedButton()
+ let id = clickBtn.id
+ let text = clickBtn.text
+ switch (id) {
+ case 21:
+ // 澶у皬鍐欏垏鎹�
+ if (englishKeyboardBig.isHide()) {
+ englishKeyboardBig.show()
+ englishKeyboardSmall.hide()
+ } else {
+ englishKeyboardBig.hide()
+ englishKeyboardSmall.show()
+ }
+ break;
+ case 29:
+ // 閫�鏍�
+ pinyin.cb({ cmd: "backspace" })
+ break;
+ case 30:
+ if (isLock) {
+ break;
+ }
+ // 鍒囨崲绗﹀彿閿洏
+ pinyin.symbolPanel.show()
+ pinyin.englishPanel.hide()
+ break;
+ case 31:
+ if (isLock) {
+ break;
+ }
+ // 鍒囨崲鏁板瓧閿洏
+ pinyin.numPanel.show()
+ pinyin.englishPanel.hide()
+ break;
+ case 33:
+ // 绌烘牸
+ pinyin.cb(" ")
+ break;
+ case 35:
+ if (isLock || !enablePinyin) {
+ break;
+ }
+ // 鍒囨崲鎷奸煶閿洏
+ pinyin.pinyinPanel.show()
+ pinyin.englishPanel.hide()
+ break;
+ case 36:
+ // 鍥炶溅
+ pinyin.cb({ cmd: "enter" })
+ break;
+ default:
+ break;
+ }
+ // 鎵撳嵃瀛楃
+ if (["q", "w", "e", "r", "t", "y", "u", "i", "o", "p",
+ "a", "s", "d", "f", "g", "h", "j", "k", "l",
+ "z", "x", "c", "v", "b", "n", "m",
+ ",", "."].includes(text) || [
+ "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P",
+ "A", "S", "D", "F", "G", "H", "J", "K", "L",
+ "Z", "X", "C", "V", "B", "N", "M",
+ ",", "."].includes(text)) {
+ pinyin.cb(text)
+ }
+ })
+ return englishKeyboard
+ }
+ // 鍒涘缓澶у皬鍐欓敭鐩�
+ let englishKeyboardBig = createKeyboard(true)
+ let englishKeyboardSmall = createKeyboard(false)
+ // 榛樿鏄皬鍐�
+ englishKeyboardBig.hide()
+ englishKeyboardSmall.show()
+ englishPanel.hide()
+ return englishPanel
+}
+
+// 鎷奸煶閿洏
+function createPinyin() {
+ let pinyinPanel = dxui.View.build(pinyin.container.id + 'pinyinPanel', pinyin.container)
+ clearStyle(pinyinPanel)
+ pinyinPanel.setSize(pinyin.container.width(), pinyin.container.height())
+ pinyinPanel.obj.lvObjAddFlag(dxui.Utils.ENUM.LV_OBJ_FLAG_OVERFLOW_VISIBLE)
+ pinyinPanel.update()
+ // 鍒涘缓姹夊瓧棰勮妗�
+ let previewBox = dxui.View.build(pinyinPanel.id + 'previewBox', pinyinPanel)
+ clearStyle(previewBox)
+ previewBox.setSize(pinyinPanel.width(), 70)
+ previewBox.align(dxui.Utils.ALIGN.TOP_LEFT, 0, -70)
+ previewBox.padLeft(20)
+ previewBox.flexFlow(dxui.Utils.FLEX_FLOW.ROW)
+ previewBox.flexAlign(dxui.Utils.FLEX_ALIGN.SPACE_AROUND, dxui.Utils.FLEX_ALIGN.CENTER, dxui.Utils.FLEX_ALIGN.CENTER)
+ previewBox.labels = []
+ // 8涓瑙堟枃瀛�
+ for (let i = 0; i < 8; i++) {
+ let labelBox = dxui.View.build(previewBox.id + 'labelBox' + i, previewBox)
+ clearStyle(labelBox)
+ labelBox.setSize(50, 70)
+ labelBox.on(dxui.Utils.ENUM.LV_EVENT_PRESSED, () => {
+ if (label.text() != " ") {
+ labelBox.bgColor(0xe6e6e6)
+ }
+ })
+ labelBox.on(dxui.Utils.ENUM.LV_EVENT_RELEASED, () => {
+ if (label.text() != " ") {
+ labelBox.bgColor(0xffffff)
+ pinyin.cb(label.text())
+ // 娓呯┖鎷奸煶锛岃繕鍘熺姸鎬�
+ phrase.text("")
+ previewBox.fillData()
+ }
+ })
+ let label = dxui.Label.build(labelBox.id + 'label' + i, labelBox)
+ label.align(dxui.Utils.ALIGN.CENTER, 0, 0)
+ label.text(" ")
+ previewBox.labels.push(label)
+ }
+ // 濉厖棰勮鏂囧瓧
+ previewBox.fillData = (str) => {
+ if (!str) {
+ // str = "寰厜浜掕仈"
+ str = ""
+ }
+ previewBox.characters = str
+ for (let i = 0; i < 8; i++) {
+ if (str.charAt(i)) {
+ previewBox.labels[i].text(str.charAt(i))
+ } else {
+ previewBox.labels[i].text(" ")
+ }
+ }
+ if (str.length > 8) {
+ // 鏂囧瓧澶氫簬8涓紝灞曠ず鏇村鏂囧瓧鎸夐挳
+ morePreview.show()
+ } else {
+ morePreview.hide()
+ }
+ }
+ // 鏇村姹夊瓧棰勮鎸夐挳
+ let morePreview = dxui.View.build(pinyinPanel.id + 'morePreview', pinyinPanel)
+ clearStyle(morePreview)
+ morePreview.setSize(70, 70)
+ morePreview.align(dxui.Utils.ALIGN.TOP_RIGHT, 0, -70)
+ morePreview.hide()
+ let rightBtn = dxui.Image.build(morePreview.id + 'rightBtn', morePreview)
+ rightBtn.source('/app/code/resource/image/right.png')
+ rightBtn.align(dxui.Utils.ALIGN.CENTER, 0, 0)
+ morePreview.on(dxui.Utils.ENUM.LV_EVENT_PRESSED, () => {
+ morePreview.bgColor(0xe6e6e6)
+ })
+ morePreview.on(dxui.Utils.ENUM.LV_EVENT_RELEASED, () => {
+ morePreview.bgColor(0xffffff)
+ morePreviewKeyboard.moveForeground()
+ morePreviewKeyboard.fillData(0)
+ morePreviewKeyboard.show()
+ })
+ // 鍒濆鐘舵��
+ previewBox.fillData()
+ // 鏇村姹夊瓧闈㈡澘
+ let morePreviewKeyboard = dxui.Buttons.build(pinyinPanel.id + 'morePreviewKeyboard', pinyinPanel)
+ clearStyle(morePreviewKeyboard)
+ morePreviewKeyboard.setSize(pinyinPanel.width(), pinyinPanel.height())
+ morePreviewKeyboard.hide()
+ morePreviewKeyboard.obj.lvObjSetStylePadGap(10, dxui.Utils.ENUM._LV_STYLE_STATE_CMP_SAME)
+ morePreviewKeyboard.padAll(10)
+ morePreviewKeyboard.bgColor(0xffffff, dxui.Utils.STYLE_PART.ITEMS)
+ morePreviewKeyboard.bgColor(0xe6e6e6)
+ morePreviewKeyboard.align(dxui.Utils.ALIGN.BOTTOM_MID, 0, 0)
+ morePreviewKeyboard.data([
+ " ", " ", " ", " ", " ", " ", " ", " ", "\n",
+ " ", " ", " ", " ", " ", " ", " ", " ", "\n",
+ " ", " ", " ", " ", " ", " ", " ", " ", "\n",
+ " ", " ", " ", " ", " ", " ", " ", " ", "\n",
+ "涓婁竴椤�", "杩斿洖", "涓嬩竴椤�",
+ ""])
+ morePreviewKeyboard.index = 0
+ // index:0绗竴椤碉紝1涓嬩竴椤碉紝-1涓婁竴椤�
+ morePreviewKeyboard.fillData = (index) => {
+ if (index == 1 && previewBox.characters.charAt((morePreviewKeyboard.index + 1) * 32)) {
+ morePreviewKeyboard.index += 1
+ } else if (index == -1 && morePreviewKeyboard.index > 0) {
+ morePreviewKeyboard.index -= 1
+ } else {
+ morePreviewKeyboard.index = 0
+ }
+ let temp = []
+ for (let i = 0; i < 32; i++) {
+ let character = previewBox.characters.charAt(i + morePreviewKeyboard.index * 32)
+ if (character) {
+ temp.push(character)
+ } else {
+ if (i == 0) {
+ // 鏃犳暟鎹�
+ return
+ }
+ temp.push(" ")
+ }
+ if ((i + 1) % 8 == 0) {
+ temp.push("\n")
+ }
+ }
+ temp.push("涓婁竴椤�")
+ temp.push("杩斿洖")
+ temp.push("涓嬩竴椤�")
+ temp.push("")
+ morePreviewKeyboard.data(temp)
+ }
+ morePreviewKeyboard.obj.addEventCb((e) => {
+ let dsc = e.lvEventGetDrawPartDsc()
+ if (dsc.class_p == morePreviewKeyboard.obj.ClassP && dsc.type == dxui.Utils.ENUM.LV_BTNMATRIX_DRAW_PART_BTN) {
+ // 鍔犳繁涓や釜鍔熻兘鎸夐挳
+ if ([32, 33, 34].includes(dsc.id)) {
+ if (morePreviewKeyboard.obj.lvBtnmatrixGetSelectedBtn() == dsc.id && e.lvEventGetTarget().hasState(dxui.Utils.ENUM.LV_STATE_PRESSED)) {
+ dxui.Utils.GG.NativeDraw.lvDrawRectReset(dsc.rect_dsc, { bg_color: 0xcdcdcd })
+ } else {
+ dxui.Utils.GG.NativeDraw.lvDrawRectReset(dsc.rect_dsc, { bg_color: 0xdbdbdb })
+ }
+ }
+ }
+ }, dxui.Utils.ENUM.LV_EVENT_DRAW_PART_BEGIN)
+ morePreviewKeyboard.on(dxui.Utils.ENUM.LV_EVENT_PRESSED, () => {
+ let clickBtn = morePreviewKeyboard.clickedButton()
+ let id = clickBtn.id
+ let text = clickBtn.text
+ if (text == "杩斿洖") {
+ morePreviewKeyboard.hide()
+ } else if (text == "涓婁竴椤�") {
+ morePreviewKeyboard.fillData(-1)
+ } else if (text == "涓嬩竴椤�") {
+ morePreviewKeyboard.fillData(1)
+ } else if (text != " ") {
+ pinyin.cb(text)
+ // 娓呯┖鎷奸煶锛岃繕鍘熺姸鎬�
+ phrase.text("")
+ previewBox.fillData()
+ morePreviewKeyboard.hide()
+ }
+ })
+ // 璇嶇粍棰勮
+ let phrasePreview = dxui.View.build(pinyinPanel.id + 'phrasePreview', pinyinPanel)
+ clearStyle(phrasePreview)
+ phrasePreview.setSize(70, 35)
+ phrasePreview.align(dxui.Utils.ALIGN.TOP_LEFT, 0, -105)
+ phrasePreview.bgColor(0xe6e6e6)
+ phrasePreview.hide()
+ let phrase = dxui.Label.build(phrasePreview.id + 'phrase', phrasePreview)
+ phrase.align(dxui.Utils.ALIGN.CENTER, 0, 0)
+ let overwrite = phrase.text
+ phrase.text = (v) => {
+ if (typeof v != 'string') {
+ // 鑾峰彇璇嶇粍
+ let temp = overwrite.call(phrase, v)
+ temp = temp == "Text" ? "" : temp
+ return temp
+ }
+ if (v.length == 0) {
+ // 璇嶇粍闀垮害涓�0灏遍殣钘�
+ overwrite.call(phrase, "Text")
+ return phrasePreview.hide()
+ }
+ if (v.length > 10) {
+ // 璇嶇粍棰勮闀垮害涓嶈秴杩�10瀛楃
+ return
+ }
+ phrasePreview.show()
+ overwrite.call(phrase, v)
+ phrase.update()
+ phrasePreview.width(phrase.width() + 40)
+ }
+ let overwrite1 = pinyinPanel.show
+ pinyinPanel.show = () => {
+ // 閲嶅啓鏄剧ず鏂规硶锛屾樉绀烘眽瀛楅瑙堟
+ previewBox.align(dxui.Utils.ALIGN.TOP_LEFT, 0, -70)
+ morePreview.align(dxui.Utils.ALIGN.TOP_RIGHT, 0, -70)
+ phrasePreview.align(dxui.Utils.ALIGN.TOP_LEFT, 0, -105)
+ overwrite1.call(pinyinPanel)
+ }
+ let overwrite2 = pinyinPanel.hide
+ pinyinPanel.hide = () => {
+ // 閲嶅啓闅愯棌鏂规硶锛岄殣钘忔眽瀛楅瑙堟
+ previewBox.align(dxui.Utils.ALIGN.TOP_LEFT, 0, 0)
+ morePreview.align(dxui.Utils.ALIGN.TOP_RIGHT, 0, 0)
+ phrasePreview.align(dxui.Utils.ALIGN.TOP_LEFT, 0, 0)
+ overwrite2.call(pinyinPanel)
+ }
+ // 鍒涘缓鎷奸煶閿洏
+ let pinyinKeyboard = dxui.Buttons.build(pinyinPanel.id + 'pinyinKeyboard', pinyinPanel)
+ clearStyle(pinyinKeyboard)
+ pinyinKeyboard.obj.lvObjSetStylePadGap(10, dxui.Utils.ENUM._LV_STYLE_STATE_CMP_SAME)
+ pinyinKeyboard.padAll(10)
+ pinyinKeyboard.bgColor(0xffffff, dxui.Utils.STYLE_PART.ITEMS)
+ pinyinKeyboard.bgColor(0xe6e6e6)
+ pinyinKeyboard.setSize(pinyinPanel.width(), pinyinPanel.height())
+ pinyinKeyboard.align(dxui.Utils.ALIGN.BOTTOM_MID, 0, 0)
+ pinyinKeyboard.data([
+ "q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "\n",
+ " ", "a", "s", "d", "f", "g", "h", "j", "k", "l", " ", "\n",
+ "鍒嗚瘝", "z", "x", "c", "v", "b", "n", "m", " ", "\n",
+ "!?#", "123", "锛�", " ", "銆�", "涓�", " ",
+ ""])
+ // 璁剧疆鎸夐挳瀹藉害
+ pinyinKeyboard.setBtnWidth(10, 1)
+ for (let i = 11; i < 20; i++) {
+ pinyinKeyboard.setBtnWidth(i, 2)
+ }
+ pinyinKeyboard.setBtnWidth(20, 1)
+ pinyinKeyboard.setBtnWidth(21, 3)
+ for (let i = 22; i < 29; i++) {
+ pinyinKeyboard.setBtnWidth(i, 2)
+ }
+ pinyinKeyboard.setBtnWidth(29, 3)
+ pinyinKeyboard.obj.addEventCb((e) => {
+ let dsc = e.lvEventGetDrawPartDsc()
+ if (dsc.class_p == pinyinKeyboard.obj.ClassP && dsc.type == dxui.Utils.ENUM.LV_BTNMATRIX_DRAW_PART_BTN) {
+ // 闅愯棌鏃犵敤鎸夐挳
+ if (dsc.id == 10 || dsc.id == 20) {
+ dxui.Utils.GG.NativeDraw.lvDrawRectReset(dsc.rect_dsc, { bg_opa: 0, shadow_opa: 0 })
+ }
+ // 鍔犳繁涓�浜涘姛鑳芥寜閽�
+ if (dsc.id == 21 || dsc.id == 29 || dsc.id == 30 || dsc.id == 31 || dsc.id == 35) {
+ if (pinyinKeyboard.obj.lvBtnmatrixGetSelectedBtn() == dsc.id && e.lvEventGetTarget().hasState(dxui.Utils.ENUM.LV_STATE_PRESSED)) {
+ dxui.Utils.GG.NativeDraw.lvDrawRectReset(dsc.rect_dsc, { bg_color: 0xcdcdcd })
+ } else {
+ dxui.Utils.GG.NativeDraw.lvDrawRectReset(dsc.rect_dsc, { bg_color: 0xdbdbdb })
+ }
+ }
+ // 鍥炶溅鎸夐挳钃濊壊
+ if (dsc.id == 36) {
+ if (pinyinKeyboard.obj.lvBtnmatrixGetSelectedBtn() == dsc.id && e.lvEventGetTarget().hasState(dxui.Utils.ENUM.LV_STATE_PRESSED)) {
+ dxui.Utils.GG.NativeDraw.lvDrawRectReset(dsc.rect_dsc, { bg_color: 0x0C6CE4 })
+ } else {
+ dxui.Utils.GG.NativeDraw.lvDrawRectReset(dsc.rect_dsc, { bg_color: 0x0C78FE })
+ }
+ }
+ }
+ }, dxui.Utils.ENUM.LV_EVENT_DRAW_PART_BEGIN)
+ pinyinKeyboard.obj.addEventCb((e) => {
+ let dsc = e.lvEventGetDrawPartDsc()
+ if (dsc.class_p == pinyinKeyboard.obj.ClassP && dsc.type == dxui.Utils.ENUM.LV_BTNMATRIX_DRAW_PART_BTN) {
+ // 鍒犻櫎鎸夐挳鍥炬娣诲姞
+ if (dsc.id == 29) {
+ let src = '/app/code/resource/image/backspace.png'
+ // 鑾峰彇鍥剧墖淇℃伅
+ let header = dxui.Utils.GG.NativeDraw.lvImgDecoderGetInfo(src)
+ // 瀹氫箟涓�鍧楀尯鍩燂紝灞呬腑鏄剧ず锛屾敞鎰忥細灏哄杞琣rea闇�瑕�-1锛宎rea杞昂瀵搁渶瑕�+1
+ let x1 = dsc.draw_area.x1 + (dsc.draw_area.x2 - dsc.draw_area.x1 + 1 - header.w) / 2;
+ let y1 = dsc.draw_area.y1 + (dsc.draw_area.y2 - dsc.draw_area.y1 + 1 - header.h) / 2;
+ let x2 = x1 + header.w - 1;
+ let y2 = y1 + header.h - 1;
+ let area = dxui.Utils.GG.NativeArea.lvAreaSet(x1, y1, x2, y2)
+ // 缁樺埗鍥剧墖淇℃伅
+ let img_draw_dsc = dxui.Utils.GG.NativeDraw.lvDrawImgDscInit()
+ // 缁樺埗鍥剧墖
+ dxui.Utils.GG.NativeDraw.lvDrawImg(dsc.dsc, img_draw_dsc, area, src)
+ }
+ // 鍥炶溅鎸夐挳鍥炬娣诲姞
+ if (dsc.id == 36) {
+ let src = '/app/code/resource/image/enter.png'
+ // 鑾峰彇鍥剧墖淇℃伅
+ let header = dxui.Utils.GG.NativeDraw.lvImgDecoderGetInfo(src)
+ // 瀹氫箟涓�鍧楀尯鍩燂紝灞呬腑鏄剧ず锛屾敞鎰忥細灏哄杞琣rea闇�瑕�-1锛宎rea杞昂瀵搁渶瑕�+1
+ let x1 = dsc.draw_area.x1 + (dsc.draw_area.x2 - dsc.draw_area.x1 + 1 - header.w) / 2;
+ let y1 = dsc.draw_area.y1 + (dsc.draw_area.y2 - dsc.draw_area.y1 + 1 - header.h) / 2;
+ let x2 = x1 + header.w - 1;
+ let y2 = y1 + header.h - 1;
+ let area = dxui.Utils.GG.NativeArea.lvAreaSet(x1, y1, x2, y2)
+ // 缁樺埗鍥剧墖淇℃伅
+ let img_draw_dsc = dxui.Utils.GG.NativeDraw.lvDrawImgDscInit()
+ // 缁樺埗鍥剧墖
+ dxui.Utils.GG.NativeDraw.lvDrawImg(dsc.dsc, img_draw_dsc, area, src)
+ }
+ // 绌烘牸鎸夐挳鍥炬娣诲姞
+ if (dsc.id == 33) {
+ let src = '/app/code/resource/image/space.png'
+ // 鑾峰彇鍥剧墖淇℃伅
+ let header = dxui.Utils.GG.NativeDraw.lvImgDecoderGetInfo(src)
+ // 瀹氫箟涓�鍧楀尯鍩燂紝灞呬腑鏄剧ず锛屾敞鎰忥細灏哄杞琣rea闇�瑕�-1锛宎rea杞昂瀵搁渶瑕�+1
+ let x1 = dsc.draw_area.x1 + (dsc.draw_area.x2 - dsc.draw_area.x1 + 1 - header.w) / 2;
+ let y1 = dsc.draw_area.y1 + (dsc.draw_area.y2 - dsc.draw_area.y1 + 1 - header.h) / 2;
+ let x2 = x1 + header.w - 1;
+ let y2 = y1 + header.h - 1;
+ y1 += 10
+ y2 += 10
+ let area = dxui.Utils.GG.NativeArea.lvAreaSet(x1, y1, x2, y2)
+ // 缁樺埗鍥剧墖淇℃伅
+ let img_draw_dsc = dxui.Utils.GG.NativeDraw.lvDrawImgDscInit()
+ // 缁樺埗鍥剧墖
+ dxui.Utils.GG.NativeDraw.lvDrawImg(dsc.dsc, img_draw_dsc, area, src)
+ }
+ }
+ }, dxui.Utils.ENUM.LV_EVENT_DRAW_PART_END)
+ // 鏌ュ瓧鍏革紝鏍规嵁杈撳叆鍐呭鏌ユ壘
+ function search() {
+ // 杈撳叆鐨勬嫾闊�
+ let searchStr = phrase.text()
+ if (searchStr.indexOf("'") >= 0) {
+ searchStr = searchStr.substring(0, searchStr.indexOf("'"))
+ }
+ if (searchStr.length <= 0) {
+ // 杈撳叆鐨勬嫾闊充负绌�
+ previewBox.fillData()
+ return
+ }
+ let characters = ""
+ let res = Object.keys(dict).filter(v => v.startsWith(searchStr))
+ if (res.length > 0) {
+ res.forEach(v => {
+ characters += dict[v]
+ })
+ }
+ previewBox.fillData(characters)
+ }
+ pinyinKeyboard.on(dxui.Utils.ENUM.LV_EVENT_LONG_PRESSED_REPEAT, () => {
+ let clickBtn = pinyinKeyboard.clickedButton()
+ let id = clickBtn.id
+ switch (id) {
+ case 29:
+ // 閫�鏍硷紝鏈夎瘝缁勫厛鍒犻櫎璇嶇粍
+ let temp = phrase.text()
+ if (temp.length > 0) {
+ phrase.text(temp.substring(0, temp.length - 1))
+ } else {
+ pinyin.cb({ cmd: "backspace" })
+ }
+ break;
+ }
+ })
+ pinyinKeyboard.on(dxui.Utils.ENUM.LV_EVENT_PRESSED, () => {
+ let clickBtn = pinyinKeyboard.clickedButton()
+ let id = clickBtn.id
+ let text = clickBtn.text
+ switch (id) {
+ case 21:
+ // 鍒嗚瘝
+ if (phrase.text().length != 0 && phrase.text().indexOf("'") < 0) {
+ phrase.text(phrase.text() + "'")
+ }
+ break;
+ case 29:
+ // 閫�鏍硷紝鏈夎瘝缁勫厛鍒犻櫎璇嶇粍
+ let temp = phrase.text()
+ if (temp.length > 0) {
+ phrase.text(temp.substring(0, temp.length - 1))
+ } else {
+ pinyin.cb({ cmd: "backspace" })
+ }
+ break;
+ case 30:
+ if (isLock) {
+ break;
+ }
+ // 鍒囨崲绗﹀彿閿洏
+ pinyin.symbolPanel.show()
+ pinyin.pinyinPanel.hide()
+ break;
+ case 31:
+ if (isLock) {
+ break;
+ }
+ // 鍒囨崲鏁板瓧閿洏
+ pinyin.numPanel.show()
+ pinyin.pinyinPanel.hide()
+ break;
+ case 33:
+ // 绌烘牸
+ pinyin.cb(" ")
+ break;
+ case 35:
+ if (isLock) {
+ break;
+ }
+ // 鍒囨崲鑻辨枃閿洏
+ pinyin.englishPanel.show()
+ pinyin.pinyinPanel.hide()
+ break;
+ case 36:
+ if (phrase.text().length > 0) {
+ pinyin.cb(phrase.text())
+ phrase.text("")
+ previewBox.fillData()
+ break;
+ }
+ // 鍥炶溅
+ pinyin.cb({ cmd: "enter" })
+ break;
+ default:
+ break;
+ }
+ // 鎵撳嵃瀛楃
+ if (["锛�", "銆�"].includes(text)) {
+ pinyin.cb(text)
+ }
+ if (["q", "w", "e", "r", "t", "y", "u", "i", "o", "p",
+ "a", "s", "d", "f", "g", "h", "j", "k", "l",
+ "z", "x", "c", "v", "b", "n", "m"].includes(text) && phrase.text().indexOf("'") < 0) {
+ phrase.text(phrase.text() + text)
+ }
+ search()
+ })
+ pinyinPanel.hide()
+ return pinyinPanel
+}
+
+// 鏁板瓧閿洏
+function createNum() {
+ let numPanel = dxui.View.build(pinyin.container.id + 'numPanel', pinyin.container)
+ clearStyle(numPanel)
+ numPanel.setSize(pinyin.container.width(), pinyin.container.height())
+ numPanel.update()
+ // 鍒涘缓鏁板瓧閿洏
+ let numKeyboard = dxui.Buttons.build(numPanel.id + 'numKeyboard', numPanel)
+ clearStyle(numKeyboard)
+ numKeyboard.obj.lvObjSetStylePadGap(10, dxui.Utils.ENUM._LV_STYLE_STATE_CMP_SAME)
+ numKeyboard.padAll(10)
+ numKeyboard.bgColor(0xffffff, dxui.Utils.STYLE_PART.ITEMS)
+ numKeyboard.bgColor(0xe6e6e6)
+ numKeyboard.setSize(numPanel.width(), numPanel.height())
+ numKeyboard.data([
+ "1", "2", "3", " ", "\n",
+ "4", "5", "6", "+", "\n",
+ "7", "8", "9", "-", "\n",
+ "ABC", "0", ".", " ", "",
+ ])
+ numKeyboard.obj.addEventCb((e) => {
+ let dsc = e.lvEventGetDrawPartDsc()
+ if (dsc.class_p == numKeyboard.obj.ClassP && dsc.type == dxui.Utils.ENUM.LV_BTNMATRIX_DRAW_PART_BTN) {
+ // 鍔犳繁涓や釜鍔熻兘鎸夐挳
+ if ([3, 7, 11, 12, 14].includes(dsc.id)) {
+ if (numKeyboard.obj.lvBtnmatrixGetSelectedBtn() == dsc.id && e.lvEventGetTarget().hasState(dxui.Utils.ENUM.LV_STATE_PRESSED)) {
+ dxui.Utils.GG.NativeDraw.lvDrawRectReset(dsc.rect_dsc, { bg_color: 0xcdcdcd })
+ } else {
+ dxui.Utils.GG.NativeDraw.lvDrawRectReset(dsc.rect_dsc, { bg_color: 0xdbdbdb })
+ }
+ }
+ // 鍥炶溅鎸夐挳钃濊壊
+ if (dsc.id == 15) {
+ if (numKeyboard.obj.lvBtnmatrixGetSelectedBtn() == dsc.id && e.lvEventGetTarget().hasState(dxui.Utils.ENUM.LV_STATE_PRESSED)) {
+ dxui.Utils.GG.NativeDraw.lvDrawRectReset(dsc.rect_dsc, { bg_color: 0x0C6CE4 })
+ } else {
+ dxui.Utils.GG.NativeDraw.lvDrawRectReset(dsc.rect_dsc, { bg_color: 0x0C78FE })
+ }
+ }
+ }
+ }, dxui.Utils.ENUM.LV_EVENT_DRAW_PART_BEGIN)
+ numKeyboard.obj.addEventCb((e) => {
+ let dsc = e.lvEventGetDrawPartDsc()
+ if (dsc.class_p == numKeyboard.obj.ClassP && dsc.type == dxui.Utils.ENUM.LV_BTNMATRIX_DRAW_PART_BTN) {
+ // 鍒犻櫎鎸夐挳鍥炬
+ if (dsc.id == 3) {
+ let src = '/app/code/resource/image/backspace.png'
+ // 鑾峰彇鍥剧墖淇℃伅
+ let header = dxui.Utils.GG.NativeDraw.lvImgDecoderGetInfo(src)
+ // 瀹氫箟涓�鍧楀尯鍩燂紝灞呬腑鏄剧ず锛屾敞鎰忥細灏哄杞琣rea闇�瑕�-1锛宎rea杞昂瀵搁渶瑕�+1
+ let x1 = dsc.draw_area.x1 + (dsc.draw_area.x2 - dsc.draw_area.x1 + 1 - header.w) / 2;
+ let y1 = dsc.draw_area.y1 + (dsc.draw_area.y2 - dsc.draw_area.y1 + 1 - header.h) / 2;
+ let x2 = x1 + header.w - 1;
+ let y2 = y1 + header.h - 1;
+ let area = dxui.Utils.GG.NativeArea.lvAreaSet(x1, y1, x2, y2)
+ // 缁樺埗鍥剧墖淇℃伅
+ let img_draw_dsc = dxui.Utils.GG.NativeDraw.lvDrawImgDscInit()
+ // 缁樺埗鍥剧墖
+ dxui.Utils.GG.NativeDraw.lvDrawImg(dsc.dsc, img_draw_dsc, area, src)
+ }
+ if (dsc.id == 15) {
+ let src = '/app/code/resource/image/enter.png'
+ // 鑾峰彇鍥剧墖淇℃伅
+ let header = dxui.Utils.GG.NativeDraw.lvImgDecoderGetInfo(src)
+ // 瀹氫箟涓�鍧楀尯鍩燂紝灞呬腑鏄剧ず锛屾敞鎰忥細灏哄杞琣rea闇�瑕�-1锛宎rea杞昂瀵搁渶瑕�+1
+ let x1 = dsc.draw_area.x1 + (dsc.draw_area.x2 - dsc.draw_area.x1 + 1 - header.w) / 2;
+ let y1 = dsc.draw_area.y1 + (dsc.draw_area.y2 - dsc.draw_area.y1 + 1 - header.h) / 2;
+ let x2 = x1 + header.w - 1;
+ let y2 = y1 + header.h - 1;
+ let area = dxui.Utils.GG.NativeArea.lvAreaSet(x1, y1, x2, y2)
+ // 缁樺埗鍥剧墖淇℃伅
+ let img_draw_dsc = dxui.Utils.GG.NativeDraw.lvDrawImgDscInit()
+ // 缁樺埗鍥剧墖
+ dxui.Utils.GG.NativeDraw.lvDrawImg(dsc.dsc, img_draw_dsc, area, src)
+ }
+ }
+ }, dxui.Utils.ENUM.LV_EVENT_DRAW_PART_END)
+ numKeyboard.on(dxui.Utils.ENUM.LV_EVENT_LONG_PRESSED_REPEAT, () => {
+ let clickBtn = numKeyboard.clickedButton()
+ let id = clickBtn.id
+ switch (id) {
+ case 3:
+ // 閫�鏍�
+ pinyin.cb({ cmd: "backspace" })
+ break;
+ }
+ })
+ numKeyboard.on(dxui.Utils.ENUM.LV_EVENT_PRESSED, () => {
+ let clickBtn = numKeyboard.clickedButton()
+ let id = clickBtn.id
+ let text = clickBtn.text
+ switch (id) {
+ case 3:
+ // 閫�鏍�
+ pinyin.cb({ cmd: "backspace" })
+ break;
+ case 12:
+ if (isLock) {
+ break;
+ }
+ // 鍒囨崲鑻辨枃閿洏
+ pinyin.englishPanel.show()
+ pinyin.numPanel.hide()
+ break;
+ case 15:
+ // 鍥炶溅
+ pinyin.cb({ cmd: "enter" })
+ break;
+ default:
+ break;
+ }
+ // 鎵撳嵃瀛楃
+ if (["1", "2", "3",
+ "4", "5", "6", "+",
+ "7", "8", "9", "-",
+ "0", "."].includes(text)) {
+ pinyin.cb(text)
+ }
+ })
+ numPanel.hide()
+ return numPanel
+}
+
+// 绗﹀彿閿洏
+function createSymbol() {
+ let symbolPanel = dxui.View.build(pinyin.container.id + 'symbolPanel', pinyin.container)
+ clearStyle(symbolPanel)
+ symbolPanel.setSize(pinyin.container.width(), pinyin.container.height())
+ symbolPanel.update()
+ // 鍒涘缓绗﹀彿閿洏
+ let symbolKeyboard = dxui.Buttons.build(symbolPanel.id + 'symbolKeyboard', symbolPanel)
+ clearStyle(symbolKeyboard)
+ symbolKeyboard.obj.lvObjSetStylePadGap(10, dxui.Utils.ENUM._LV_STYLE_STATE_CMP_SAME)
+ symbolKeyboard.padAll(10)
+ symbolKeyboard.bgColor(0xffffff, dxui.Utils.STYLE_PART.ITEMS)
+ symbolKeyboard.bgColor(0xe6e6e6)
+ symbolKeyboard.setSize(symbolPanel.width(), symbolPanel.height())
+ symbolKeyboard.data([
+ "^", "\\", "|", "<", ">", "垄", "拢", "鈧�", "楼", "鈧�", "\n",
+ "[", "]", "{", "}", "#", "%", "+", "=", "~", "_", "\n",
+ " ", "-", "/", ":", ";", "(", ")", "$", "&", "\"", " ", "\n",
+ "123", "`", "?", "!", "*", "@", ",", "'", " ", "\n",
+ "ABC", " ", " ", ""
+ ])
+ symbolKeyboard.setBtnWidth(20, 1)
+ for (let i = 21; i < 30; i++) {
+ symbolKeyboard.setBtnWidth(i, 2)
+ }
+ symbolKeyboard.setBtnWidth(30, 1)
+ symbolKeyboard.setBtnWidth(31, 3)
+ for (let i = 32; i < 39; i++) {
+ symbolKeyboard.setBtnWidth(i, 2)
+ }
+ symbolKeyboard.setBtnWidth(39, 3)
+ symbolKeyboard.setBtnWidth(41, 2)
+ symbolKeyboard.obj.addEventCb((e) => {
+ let dsc = e.lvEventGetDrawPartDsc()
+ if (dsc.class_p == symbolKeyboard.obj.ClassP && dsc.type == dxui.Utils.ENUM.LV_BTNMATRIX_DRAW_PART_BTN) {
+ // 闅愯棌鏃犵敤鎸夐挳
+ if (dsc.id == 20 || dsc.id == 30) {
+ dxui.Utils.GG.NativeDraw.lvDrawRectReset(dsc.rect_dsc, { bg_opa: 0, shadow_opa: 0 })
+ }
+ // 鍔犳繁涓�浜涘姛鑳芥寜閽�
+ if (dsc.id == 31 || dsc.id == 39 || dsc.id == 40 || dsc.id == 41 || dsc.id == 45) {
+ if (symbolKeyboard.obj.lvBtnmatrixGetSelectedBtn() == dsc.id && e.lvEventGetTarget().hasState(dxui.Utils.ENUM.LV_STATE_PRESSED)) {
+ dxui.Utils.GG.NativeDraw.lvDrawRectReset(dsc.rect_dsc, { bg_color: 0xcdcdcd })
+ } else {
+ dxui.Utils.GG.NativeDraw.lvDrawRectReset(dsc.rect_dsc, { bg_color: 0xdbdbdb })
+ }
+ }
+ // 鍥炶溅鎸夐挳钃濊壊
+ if (dsc.id == 42) {
+ if (symbolKeyboard.obj.lvBtnmatrixGetSelectedBtn() == dsc.id && e.lvEventGetTarget().hasState(dxui.Utils.ENUM.LV_STATE_PRESSED)) {
+ dxui.Utils.GG.NativeDraw.lvDrawRectReset(dsc.rect_dsc, { bg_color: 0x0C6CE4 })
+ } else {
+ dxui.Utils.GG.NativeDraw.lvDrawRectReset(dsc.rect_dsc, { bg_color: 0x0C78FE })
+ }
+ }
+ }
+ }, dxui.Utils.ENUM.LV_EVENT_DRAW_PART_BEGIN)
+ symbolKeyboard.obj.addEventCb((e) => {
+ let dsc = e.lvEventGetDrawPartDsc()
+ if (dsc.class_p == symbolKeyboard.obj.ClassP && dsc.type == dxui.Utils.ENUM.LV_BTNMATRIX_DRAW_PART_BTN) {
+ if (dsc.id == 39) {
+ let src = '/app/code/resource/image/backspace.png'
+ // 鑾峰彇鍥剧墖淇℃伅
+ let header = dxui.Utils.GG.NativeDraw.lvImgDecoderGetInfo(src)
+ // 瀹氫箟涓�鍧楀尯鍩燂紝灞呬腑鏄剧ず锛屾敞鎰忥細灏哄杞琣rea闇�瑕�-1锛宎rea杞昂瀵搁渶瑕�+1
+ let x1 = dsc.draw_area.x1 + (dsc.draw_area.x2 - dsc.draw_area.x1 + 1 - header.w) / 2;
+ let y1 = dsc.draw_area.y1 + (dsc.draw_area.y2 - dsc.draw_area.y1 + 1 - header.h) / 2;
+ let x2 = x1 + header.w - 1;
+ let y2 = y1 + header.h - 1;
+ let area = dxui.Utils.GG.NativeArea.lvAreaSet(x1, y1, x2, y2)
+ // 缁樺埗鍥剧墖淇℃伅
+ let img_draw_dsc = dxui.Utils.GG.NativeDraw.lvDrawImgDscInit()
+ // 缁樺埗鍥剧墖
+ dxui.Utils.GG.NativeDraw.lvDrawImg(dsc.dsc, img_draw_dsc, area, src)
+ }
+ if (dsc.id == 42) {
+ let src = '/app/code/resource/image/enter.png'
+ // 鑾峰彇鍥剧墖淇℃伅
+ let header = dxui.Utils.GG.NativeDraw.lvImgDecoderGetInfo(src)
+ // 瀹氫箟涓�鍧楀尯鍩燂紝灞呬腑鏄剧ず锛屾敞鎰忥細灏哄杞琣rea闇�瑕�-1锛宎rea杞昂瀵搁渶瑕�+1
+ let x1 = dsc.draw_area.x1 + (dsc.draw_area.x2 - dsc.draw_area.x1 + 1 - header.w) / 2;
+ let y1 = dsc.draw_area.y1 + (dsc.draw_area.y2 - dsc.draw_area.y1 + 1 - header.h) / 2;
+ let x2 = x1 + header.w - 1;
+ let y2 = y1 + header.h - 1;
+ let area = dxui.Utils.GG.NativeArea.lvAreaSet(x1, y1, x2, y2)
+ // 缁樺埗鍥剧墖淇℃伅
+ let img_draw_dsc = dxui.Utils.GG.NativeDraw.lvDrawImgDscInit()
+ // 缁樺埗鍥剧墖
+ dxui.Utils.GG.NativeDraw.lvDrawImg(dsc.dsc, img_draw_dsc, area, src)
+ }
+ if (dsc.id == 41) {
+ let src = '/app/code/resource/image/space.png'
+ // 鑾峰彇鍥剧墖淇℃伅
+ let header = dxui.Utils.GG.NativeDraw.lvImgDecoderGetInfo(src)
+ // 瀹氫箟涓�鍧楀尯鍩燂紝灞呬腑鏄剧ず锛屾敞鎰忥細灏哄杞琣rea闇�瑕�-1锛宎rea杞昂瀵搁渶瑕�+1
+ let x1 = dsc.draw_area.x1 + (dsc.draw_area.x2 - dsc.draw_area.x1 + 1 - header.w) / 2;
+ let y1 = dsc.draw_area.y1 + (dsc.draw_area.y2 - dsc.draw_area.y1 + 1 - header.h) / 2;
+ let x2 = x1 + header.w - 1;
+ let y2 = y1 + header.h - 1;
+ y1 += 10
+ y2 += 10
+ let area = dxui.Utils.GG.NativeArea.lvAreaSet(x1, y1, x2, y2)
+ // 缁樺埗鍥剧墖淇℃伅
+ let img_draw_dsc = dxui.Utils.GG.NativeDraw.lvDrawImgDscInit()
+ // 缁樺埗鍥剧墖
+ dxui.Utils.GG.NativeDraw.lvDrawImg(dsc.dsc, img_draw_dsc, area, src)
+ }
+ }
+ }, dxui.Utils.ENUM.LV_EVENT_DRAW_PART_END)
+ symbolKeyboard.on(dxui.Utils.ENUM.LV_EVENT_LONG_PRESSED_REPEAT, () => {
+ let clickBtn = symbolKeyboard.clickedButton()
+ let id = clickBtn.id
+ switch (id) {
+ case 39:
+ // 閫�鏍�
+ pinyin.cb({ cmd: "backspace" })
+ break;
+ }
+ })
+ symbolKeyboard.on(dxui.Utils.ENUM.LV_EVENT_PRESSED, () => {
+ let clickBtn = symbolKeyboard.clickedButton()
+ let id = clickBtn.id
+ let text = clickBtn.text
+ switch (id) {
+ case 31:
+ if (isLock) {
+ break;
+ }
+ // 鍒囨崲鏁板瓧閿洏
+ pinyin.numPanel.show()
+ pinyin.symbolPanel.hide()
+ break;
+ case 39:
+ // 閫�鏍�
+ pinyin.cb({ cmd: "backspace" })
+ break;
+ case 40:
+ if (isLock) {
+ break;
+ }
+ // 鍒囨崲鑻辨枃閿洏
+ pinyin.englishPanel.show()
+ pinyin.symbolPanel.hide()
+ break;
+ case 41:
+ // 绌烘牸
+ pinyin.cb(" ")
+ break;
+ case 42:
+ // 鍥炶溅
+ pinyin.cb({ cmd: "enter" })
+ break;
+ default:
+ break;
+ }
+ // 鎵撳嵃瀛楃
+ if (["^", "\\", "|", "<", ">", "垄", "拢", "鈧�", "楼", "鈧�",
+ "[", "]", "{", "}", "#", "%", "+", "=", "~", "_",
+ "-", "/", ":", ";", "(", ")", "$", "&", "\"",
+ "`", "?", "!", "*", "@", ",", "'"].includes(text)) {
+ pinyin.cb(text)
+ }
+ })
+ symbolPanel.hide()
+ return symbolPanel
+}
+// 娓呴櫎鏍峰紡
+function clearStyle(obj) {
+ obj.radius(0)
+ obj.borderWidth(0)
+ obj.padAll(0)
+}
+export default pinyin
--
Gitblit v1.9.3