hi? Are you using the site tutorial? I updated it a few weeks ago, and it should work. The events files are already included, see: http://dynapi.sourceforge.net/doccenter/index.php?Widgets
This is the code from that tutorial, just save it in the /examples directory, and it works: <html> <head><title>DynAPI2 tutor - button widget</title> <Script language="Javascript" src="../src/dynapi.js"></script> <Script language="Javascript"> DynAPI.setLibraryPath('../src/lib/') DynAPI.include('dynapi.api.*') DynAPI.include('dynapi.event.*') </script> <script language="Javascript"> DynAPI.onLoad=function() { myButton=new button('mybutton',100,100,80,23,'<center>Ok<\/center>') myListener=new EventListener(myButton) myListener.onpressed=function(e) { alert('Don\'t hit me!') } myButton.addEventListener(myListener) DynAPI.document.addChild(myButton) } //The widget (later we include it as a .js file) function button(id,x,y,w,h,caption) { this.dynlayer=DynLayer this.dynlayer(id,x,y,w,h) this.caption=caption||'' this.addEventListener(button.listener) return this } button.prototype=new DynLayer() button.listener=new EventListener() button.listener.onprecreate=function(e) { var o=e.getSource() o.setBgColor('#c0c0c0') // make the widget look gray o.dyncaption=new DynLayer(null,1,1,o.w-2,o.h-2) // create child layer for caption o.dyncaption.setHTML(o.caption) o.addChild(o.dyncaption) // add 3D looking borders at the edges of the widget o.BorderL=new DynLayer(null,0,0,1,o.h,'#f0f0f0') o.BorderT=new DynLayer(null,0,0,o.w,1,'#f0f0f0') o.BorderR=new DynLayer(null,o.w-1,1,1,o.h-1,'#808080') o.BorderB=new DynLayer(null,1,o.h-1,o.w-1,1,'#808080') o.addChild(o.BorderL) o.addChild(o.BorderT) o.addChild(o.BorderR) o.addChild(o.BorderB) o.setVisible(true) // make sure the widget is visible o.dynevents=new DynLayer(null,0,0,o.w,o.h) // add layer for event handling o.addChild(o.dynevents) } button.listener.onmousedown=function(e) { // add onmousedown handler var o=e.getSource() // switch colors to make the button look pressed o.BorderL.setBgColor('#808080') o.BorderR.setBgColor('#f0f0f0') o.BorderT.setBgColor('#808080') o.BorderB.setBgColor('#f0f0f0') } button.listener.onmouseup=function(e) { o=e.getSource() // switch colors to make the button look normal o.BorderL.setBgColor('#f0f0f0') o.BorderR.setBgColor('#808080') o.BorderT.setBgColor('#f0f0f0') o.BorderB.setBgColor('#808080') o.invokeEvent("pressed") } </script> </head> <body> </body> </html> Cheers, Richard. www.richardinfo.com ----- Original Message ----- From: "Daniel Rubio" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, October 31, 2001 12:38 PM Subject: [Dynapi-Help] Can't create a widget > Hi! > > I'm starting to use Dynapi 2, I've downloaded the 2.55a version, and now > i was following the tutorial chapter to create a widget. > I made a Cut & paste from the example in the tutorial and it doesn't > work!. Looking at the errors I've seen that EventListener was not > defined, and I've imported: DynAPI.include('dynapi.event.*'); > > Now there's no error, but there's not button too : ( > > I've put an alert message into the function called onprecreate and it > does'nt appear anywhere. > Is the error here? someone else has the same problem? > > Thanks and sorry by my english : P > > -- > ------------------------------------------------- > Daniel Rubio Rodríguez <[EMAIL PROTECTED]> > Responsable de Desarrollo > ------------------------------------------------- > Activa-Online S.A. > Rambla Nova, 26-28 (entlo) > Tarragona - Spain > tel. +34 977 250 966 > fax +34 977 241 694 > ------------------------------------------------- > http://www.activa-online.com > > > > _______________________________________________ > Dynapi-Help mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/dynapi-help > _______________________________________________ Dynapi-Help mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/dynapi-help