优化菜单按钮响应代码,由网友提供:https://aarbbs.com/198.html#comment-104

This commit is contained in:
一二三 2024-09-17 22:47:28 +08:00
parent efc8e21f46
commit 5c49d2ecc8

View File

@ -264,86 +264,53 @@ class TeMenu{
}; };
this.init(); this.init();
}; };
setCommandFunc = function(side, idx, func){
select(side) { getSid = function(side, idx) {
case 0 { var std = {};
if (idx > 0 and idx <= #this.toolbars_left) { if (side == 0) {
var ctrl = winform['plus_left'+idx]; std.sd = "plus_left";
winform['plus_left'+idx].oncommand = func(ctrl); std.n = #this.toolbars_left;
} } else {
else { std.sd = "plus_right";
return false; std.n = #this.toolbars_right;
} }
}
case 1 { if (idx > 0 && idx <= std.n) {
if (idx > 0 and idx <= #this.toolbars_right) { std.ctrl = winform[std.sd ++ idx];
var ctrl = winform['plus_right'+idx]; return std;
winform['plus_right'+idx].oncommand = func(ctrl); }
} return;
else { }
return false;
} setCommandFunc = function(side, idx, func) {
} var std = this.getSid(side, idx);
else { if (std) {
return false; std.ctrl.oncommand = func(std.ctrl);
} } else {
} return;
}; }
setRightClickFunc = function(side, idx, func){ }
select(side) {
case 0 { setRightClickFunc = function(side, idx, func) {
if (idx > 0 and idx <= #this.toolbars_left) { var std = this.getSid(side, idx);
var ctrl = winform['plus_left'+idx]; if (std) {
winform['plus_left'+idx].wndproc = function(hwnd,message,wParam,lParam){ std.ctrl.wndproc = function(hwnd, message, wParam, lParam) {
if (message == 0x205/*_WM_RBUTTONUP*/) { if (message == 0x205 /*_WM_RBUTTONUP*/) {
func(ctrl); func(std.ctrl);
} }
} }
} } else {
else { return;
return false; }
} }
}
case 1 { disabled = function(side, idx, status) {
if (idx > 0 and idx <= #this.toolbars_right) { var std = this.getSid(side, idx);
var ctrl = winform['plus_right'+idx]; if (std) {
winform['plus_right'+idx].wndproc = function(hwnd,message,wParam,lParam){ std.ctrl.disabled = status;
if (message == 0x205/*_WM_RBUTTONUP*/) { } else {
func(ctrl); return;
}
}
}
else {
return false;
}
}
else {
return false;
}
} }
} }
disabled = function(side, idx, status){
select(side) {
case 0 {
if (idx > 0 and idx <= #this.toolbars_left) {
winform['plus_left'+idx].disabled = status;
}
else {
return false;
}
}
case 1 {
if (idx > 0 and idx <= #this.toolbars_right) {
winform['plus_right'+idx].disabled = status;
}
else {
return false;
}
}
else {
return false;
}
}
};
} }