根据edit框中鼠标位置加减数值
By
admin
at 2018-09-30 • 0人收藏 • 1474人看过
var editAutoInc = function(ctrl){ var n,length = tonumber(ctrl.text); if( length == #ctrl.text ){ var mousePos = ctrl.getsel(); var tab = string.split(ctrl.text) var s = null; for(k,v in tab){ if((k == 1) and (v == "-")){ continue ; } if(k == mousePos){ if(v == "."){ continue ; } v = 1; }else { if(tonumber(v)) v=0; } s = string.concat(s,v); } var ret = tonumber(s); return ret,mousePos; }else return null; }
2 个回复 | 最后更新于 2018-12-25
记录:
编号框里除其他字母外,数字自加1和自减1
mainForm.芯片编号.wndproc = function(hwnd,message,wParam,lParam){ select(message) { case 0x20A/*_WM_MOUSEWHEEL*/ { var wheelDelta = raw.convert({int wParam=wParam },{word vk;word delta}).delta; if( wheelDelta > 0 ){ var pos = owner.getsel(); var cNum = (tonumber(string.match(owner.text,"\d+$")))+1; owner.text = string.replace(owner.text,"\d+$",cNum ); owner.setsel(pos); }else { var pos = owner.getsel(); var cNum = (tonumber(string.match(owner.text,"\d+$")))-1; if(cNum<=0){ cNum = 0; } owner.text = string.replace(owner.text,"\d+$",cNum ); owner.setsel(pos); } } } }
登录后方可回帖
加入各种判断之后的完整代码如下: