优化菜单按钮响应代码,由网友提供: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 {
std.sd = "plus_right";
std.n = #this.toolbars_right;
} }
else {
return false; if (idx > 0 && idx <= std.n) {
std.ctrl = winform[std.sd ++ idx];
return std;
}
return;
}
setCommandFunc = function(side, idx, func) {
var std = this.getSid(side, idx);
if (std) {
std.ctrl.oncommand = func(std.ctrl);
} else {
return;
} }
} }
case 1 {
if (idx > 0 and idx <= #this.toolbars_right) { setRightClickFunc = function(side, idx, func) {
var ctrl = winform['plus_right'+idx]; var std = this.getSid(side, idx);
winform['plus_right'+idx].oncommand = func(ctrl); if (std) {
} std.ctrl.wndproc = function(hwnd, message, wParam, lParam) {
else { if (message == 0x205 /*_WM_RBUTTONUP*/) {
return false; func(std.ctrl);
} }
} }
else { } else {
return false; return;
} }
} }
};
setRightClickFunc = function(side, idx, func){ disabled = function(side, idx, status) {
select(side) { var std = this.getSid(side, idx);
case 0 { if (std) {
if (idx > 0 and idx <= #this.toolbars_left) { std.ctrl.disabled = status;
var ctrl = winform['plus_left'+idx]; } else {
winform['plus_left'+idx].wndproc = function(hwnd,message,wParam,lParam){ return;
if (message == 0x205/*_WM_RBUTTONUP*/) {
func(ctrl);
} }
} }
}
else {
return false;
}
}
case 1 {
if (idx > 0 and idx <= #this.toolbars_right) {
var ctrl = winform['plus_right'+idx];
winform['plus_right'+idx].wndproc = function(hwnd,message,wParam,lParam){
if (message == 0x205/*_WM_RBUTTONUP*/) {
func(ctrl);
}
}
}
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;
}
}
};
} }