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; - } - } - }; }