Currently, the object has on_mouse methods, and it is the responsibility of the main code to call them. The object's method returns false when it has used the event (for example, when the user has clicked on the scrollbar), so it is relatively easy to handle the remaining events in the WSH panel. But I'm not satisfied by that method, mainly because it is necessary to define the callbacks needed by the scrollbar in the main code, even if it doesn't need that callbacks for its own use, just to pass them to the main code.
i use true like this...
function on_mouse_lbtn_up(x, y) {
switch(true) {
case obj1.trace(x, y):
obj1.click(x, y);
break;
case obj2.trace(x, y):
obj2.click(x, y);
break;
case ..... //neither of those objects was clicked so let's check something else....
}
}
I've tried to do the opposite: define the callback functions in the include, then pass the events to the object, and if they have not been used, call a function with a similar but somewhat different name in the main code (with try/catch so that the code will not fail if the function is not defined).
i don't like this idea at all. i definitely prefer the proper callbacks in the panels themselves. i think it makes maintenance easier and gives you more flexibility to make changes.
as for duplicating functions, that's certainly possible as i discovered by mistake. if you declare them multiple times, only the last one gets called.
function test(a, b) {
return a + b;
}
function test(a, b) {
return a * b;
}
fb.trace(test(5, 5)); //displays 25 in the console
i can't say i'm keen on this idea either but i'm not particularly fussy. so long as stuff works, there is no impact on performance and it doesn't crash - that's good enough.