From: Richard B. <ric...@us...> - 2001-11-02 01:55:07
|
Update of /cvsroot/dynapi/dynapi/tests In directory usw-pr-cvs1:/tmp/cvs-serv17774 Added Files: secondary_inheritance.html Log Message: testfile for secondary inheritance problem outlined in bug 425789 --- NEW FILE --- <html> <head> <title>Secondary inheritance test</title> </head> <script language="Javascript" src="../src/dynapi.js"></script> <script language="Javascript"> DynAPI.setLibraryPath('../src/lib/') DynAPI.include('dynapi.api.*'); DynAPI.include('dynapi.event.*') DynAPI.include('dynapi.util.thread.js'); DynAPI.include('dynapi.util.pathanim.js'); DynAPI.include('dynapi.gui.dynimage.js'); DynAPI.include('dynapi.gui.button.js'); DynAPI.include('dynapi.gui.scrollbar.js'); DynAPI.include('dynapi.gui.viewport.js'); DynAPI.include('dynapi.gui.scrollpane.js'); DynAPI.include('dynapi.gui.label.js'); DynAPI.onLoad=function() { label1 = new Label('<table border=1><tr><td width=160 height=160>label 1 alk jskj slkj k dkjkj dk skslkdjf lskd f</td></tr></table>') label1.setWrap(false) label1.setPadding(5) label1.setBgColor('cyan') label1.setSize(160,160) label2 = new Label('<table border=1><tr><td width=160 height=160>label 1 alk jskj slkj k dkjkj dk skslkdjf lskd f</td></tr></table>') label2.setWrap(false) label2.setPadding(5) label2.setBgColor('cyan') label2.setSize(160,160) //SCROLLPANE#1 var scrollpane1 = new ScrollPane(label1); scrollpane1.setSize(150,150) scrollpane1.moveTo(50,150) scrollpane1.setBgColor('#c0c0c0') //EVENT LISTENERS var EListener1 = new EventListener(); EListener1.oncreate = function(e) { var o=e.getSource(); alert("from SP1: "+o.id); }; EListener1.onclick = function(e) { var o=e.getSource(); alert("from SP1: "+o.id); }; scrollpane1.addEventListener(EListener1); DynAPI.document.addChild(scrollpane1); //SCROLLPANE#2 var scrollpane2 = new ScrollPane(label2); scrollpane2.setSize(150,150) scrollpane2.moveTo(250,150) scrollpane2.setBgColor('#c0c0c0') DynAPI.document.addChild(scrollpane2); } </script> <body bgcolor="#ffffff"> <b>Issue:</b><br /> The problem we have here, is that secondary inheritance isn't working well.<br /> We have two scrollpanes here, only the first one has an eventlistener, but both return events.<br /> The problem arises because scrollpane inherits from viewport, which inherits from dynlayer. <br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /> <b>More info:</b> Basically any widget that does not inherit directly from DynLayer can not be<br /> used more than once on a single page, unless you only want one EventListener<br /> for the whole lot (very unlikely).<br /><br /> If you try to create multiple EventListeners (i.e. one for each widget of a<br /> class not derived directly from DynLayers), only the last EventListener<br /> assigned to one of this second generation widgets will fire. And it will<br /> fire on all widgets that are instances of the same class.<br /><br /> I have been mainly working with the ButtonImage class derived from DynImage,<br /> but I believe this will affect List, PushPanel and any other second<br /> generation widget.<br /><br /> Seeing that this problem has been around for some time, I imagine the<br /> solution will require a lot of work. A temporary solution would be to<br /> rewrite any second generation widget to inherit directly from DynLayer and<br /> including any other inherited functions from it's former parent. I realize<br /> this is redundant and counter to OOP, but at least we would have complex<br /> widgets that work. There is no point in streamlining the core for<br /> performance if the core is broken. This would be a relatively simple fix.<br /> And could be reversed easily once the event model is fixed. This would also<br /> not require changes in code implementing these widgets, thus have little<br /> effect on users other than performance due to redundancy.<br /><br /> The other solution is to fix the problem in the event model. This will take<br /> longer, but should be top priority. The whole purpose of DynAPI is to have<br /> complex widgets, and a common API. For simple widgets anyone can create<br /> simple JavaScript that has less overhead than DynAPI. Therefore this bug<br /> undermines the purpose of DynAPI.<br /><br /> We did not have this bug in 2.0. What has changed so drastically since 2.0<br /> in the event model or in other parts of the core that introduced this bug?<br /> <br /><br /> </body> </html> |