From bcfd1899b76fd4202c9548399957e5565f8a2b46 Mon Sep 17 00:00:00 2001 From: oc Date: Wed, 21 Nov 2018 23:42:40 +0800 Subject: [PATCH] delay on choices --- libs/actions.js | 86 +++++++++++++++++++++++++++++++++++++++++++++++++ libs/events.js | 2 +- 2 files changed, 87 insertions(+), 1 deletion(-) diff --git a/libs/actions.js b/libs/actions.js index 4d829c8e..94ad235e 100644 --- a/libs/actions.js +++ b/libs/actions.js @@ -767,6 +767,12 @@ actions.prototype.clickAction = function (x,y) { ////// 自定义事件时,按下某个键的操作 ////// actions.prototype.keyDownAction = function (keycode) { + // 视为无效 + var startTime = core.status.event.data.startTime||0; + if (startTime>0 && new Date().getTime()-startTime<250) + return; + core.status.event.data.startTime = 0; + if (core.status.event.data.type=='choices') { var data = core.status.event.data.current; var choices = data.choices; @@ -809,6 +815,15 @@ actions.prototype.keyUpAction = function (keycode) { core.insertAction(choices[core.status.event.selection].action); core.doAction(); } + // 数字键快速选择 + if (keycode>=49 && keycode<=57) { + var index = keycode-49; + if (index=49 && keycode<=57) { + var index = keycode-49; + if (index<=choices.length) { + var topIndex = 6 - parseInt(choices.length / 2); + this.clickShop(6, topIndex+index); + } + } return; } @@ -1184,6 +1207,13 @@ actions.prototype.keyUpQuickShop = function (keycode) { var topIndex = 6 - parseInt(keys.length / 2); this.clickQuickShop(6, topIndex+core.status.event.selection); } + if (keycode>=49 && keycode<=57) { + var index = keycode-49; + if (index<=keys.length) { + var topIndex = 6 - parseInt(keys.length / 2); + this.clickQuickShop(6, topIndex+index); + } + } return; } @@ -1826,6 +1856,14 @@ actions.prototype.keyUpSwitchs = function (keycode) { var topIndex = 6 - parseInt((choices.length - 1) / 2); this.clickSwitchs(6, topIndex+core.status.event.selection); } + // 数字键快速选择 + if (keycode>=49 && keycode<=57) { + var index = keycode-49; + if (index=49 && keycode<=57) { + var index = keycode-49; + if (index=49 && keycode<=57) { + var index = keycode-49; + if (index=49 && keycode<=57) { + var index = keycode-49; + if (index=49 && keycode<=57) { + var index = keycode-49; + if (index=49 && keycode<=57) { + var index = keycode-49; + if (index=49 && keycode<=57) { + var index = keycode-49; + if (index