修复输入框响应区域错误,右方向键控制失效

This commit is contained in:
MrZ626
2020-10-21 12:22:28 +08:00
parent 6d868899b2
commit a7f9616552

View File

@@ -657,8 +657,8 @@ function WIDGET.newTextBox(D)
regex= D.regex,
resCtr={
D.x+.5,D.y,
D.x+D.w*.2,D.y,
D.x+D.w*.5,D.y,
D.x+D.w*.8,D.y,
},
@@ -773,7 +773,7 @@ end
function WIDGET.keyPressed(key)
if key=="space"or key=="return"then
WIDGET.press()
elseif kb.isDown("lshift","lalt","lctrl")and key=="left"or key=="right"then
elseif kb.isDown("lshift","lalt","lctrl")and(key=="left"or key=="right")then
--When hold [↑], control slider with left/right
local W=WIDGET.sel
if not W then return end
@@ -790,7 +790,7 @@ function WIDGET.keyPressed(key)
end
elseif W.type=="selector"then
local s=W.select
if not ((isLeft and s > 1) or ((not isLeft) and s < #W.list)) then return end
if isLeft and s==1 or not isLeft and s==#W.list then return end
if isLeft then
s=s-1
sysFX.newShade(.3,1,1,1,W.x,W.y,W.w*.5,60)
@@ -819,9 +819,9 @@ function WIDGET.keyPressed(key)
local dir=(key=="right"or key=="down")and 1 or -1
local tar
local minDist=1e99
local swap_xy = not (key=="left" or key == "right")
local swap_xy=key=="up"or key=="down"
if swap_xy then WX,WY=WY,WX end -- note that we do not swap them back later
for i, W1 in ipairs(WIDGET.active) do
for _,W1 in ipairs(WIDGET.active)do
if W~=W1 and W1.resCtr then
local L=W1.resCtr
for j=1,#L,2 do
@@ -830,6 +830,7 @@ function WIDGET.keyPressed(key)
local dist=(x-WX)*dir
if dist>10 then
dist=dist+abs(y-WY)*6.26
print(W1.name,dist)
if dist<minDist then
minDist=dist
tar=W1
@@ -843,7 +844,7 @@ function WIDGET.keyPressed(key)
end
elseif WIDGET.sel and WIDGET.sel.type=="textBox"then
local t=WIDGET.sel.value
if #t <= 0 then return end
if #t==0 then return end
if key=="backspace"then
while t:byte(#t)>=128 and t:byte(#t)<192 do
t=sub(t,1,-2)