From 5c49d2ecc87815db55c8d9c8e28c46a7153cf20d Mon Sep 17 00:00:00 2001 From: Crimson Date: Tue, 17 Sep 2024 22:47:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=8F=9C=E5=8D=95=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E5=93=8D=E5=BA=94=E4=BB=A3=E7=A0=81=EF=BC=8C=E7=94=B1?= =?UTF-8?q?=E7=BD=91=E5=8F=8B=E6=8F=90=E4=BE=9B=EF=BC=9Ahttps://aarbbs.com?= =?UTF-8?q?/198.html#comment-104?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/teMenu.aardio | 125 +++++++++++++++++----------------------------- 1 file changed, 46 insertions(+), 79 deletions(-) diff --git a/lib/teMenu.aardio b/lib/teMenu.aardio index 823882d..10a1ab4 100644 --- a/lib/teMenu.aardio +++ b/lib/teMenu.aardio @@ -264,86 +264,53 @@ class TeMenu{ }; this.init(); }; - setCommandFunc = function(side, idx, func){ - select(side) { - case 0 { - if (idx > 0 and idx <= #this.toolbars_left) { - var ctrl = winform['plus_left'+idx]; - winform['plus_left'+idx].oncommand = 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].oncommand = func(ctrl); - } - else { - return false; - } - } - else { - return false; - } - } - }; - setRightClickFunc = function(side, idx, func){ - select(side) { - case 0 { - if (idx > 0 and idx <= #this.toolbars_left) { - var ctrl = winform['plus_left'+idx]; - winform['plus_left'+idx].wndproc = function(hwnd,message,wParam,lParam){ - 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; - } + + getSid = function(side, idx) { + var std = {}; + if (side == 0) { + std.sd = "plus_left"; + std.n = #this.toolbars_left; + } else { + std.sd = "plus_right"; + std.n = #this.toolbars_right; + } + + 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; + } + } + + setRightClickFunc = function(side, idx, func) { + var std = this.getSid(side, idx); + if (std) { + std.ctrl.wndproc = function(hwnd, message, wParam, lParam) { + if (message == 0x205 /*_WM_RBUTTONUP*/) { + func(std.ctrl); + } + } + } else { + return; + } + } + + disabled = function(side, idx, status) { + var std = this.getSid(side, idx); + if (std) { + std.ctrl.disabled = status; + } else { + return; } } - 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; - } - } - }; }