Hi all, Maybe I didn't explain well.
My idea is to have a Info button that activates the option to get info from a wfs layer. If I didn't, the wfsLayer.events.on, mousedown event disables buttons from toogle bar (zoom in, zoom out, pan, etc.). Instead of, I would add the mentioned "Info" button, and when user activates, then, click over the wfs layer (using mousedown event from wfslayer) show several attributes from wfs request (this works fine). Sorry for bad first email. Antoni Vidal Unitat d'Aplicacions SIG-WEB Institut Cartogràfic de Catalunya Parc de Montjuïc, E-08038 Barcelona Tel. (+34) 93 567 15 00 (ext. 3228) www.icc.cat -----Missatge original----- De: Matt Priour [mailto:[email protected]] Enviat: viernes, 07 de enero de 2011 15:14 Per a: Oscar Fonts; Vidal, Antoni A/c: [email protected] Tema: Re: [Users] How to add register to Action You don't to implement your own mousedown event listener or toggleHandler when using a GeoExt.Action in a toolbar. GeoExt.Action will default to a button and already has handlers for activating/decativating controls. You really want to use a real control not the OpenLayers.Control base class. If you need to build your own control then you should subclass the OpenLayers.Control class and then use your own subclass. Because of the way you have written the code below, it is highly doubtful that 'this' refers to what you want and there is probably no handleMousedown function in the object 'this' refers to. Other than that, this section looks ok: action = new GeoExt.Action({ control: new OpenLayers.Control({eventListeners: {"mousedown": this.handleMousedown}}), tooltip: 'Info', map: map, iconCls: 'drawpolygon', toggleGroup: 'map' }); You don't need to re-add the 'mousedown' event listener, so this section is not needed: action.control.events.on({ "mousedown": handleMousedown }); Next, I don't know what you are doing with the 'actions' array that you are pushing the newly created 'action' into. I'm going to assume that you are using the 'actions' array as a value for the map panel's tbar config property: actions.push(action); Hope that helps Matt Priour Kestrel Computer Consulting -------------------------------------------------- From: "Oscar Fonts" <[email protected]> Sent: Friday, January 07, 2011 6:53 AM To: "Vidal, Antoni" <[email protected]> Cc: <[email protected]> Subject: Re: [Users] How to add register to Action > Toni, why not let Ext.Button handle the event? > Something like > > var infoButton = new Ext.Button({ > tooltip: 'Informació', > iconCls: "icon-getfeatureinfo", > enableToggle: true, > toggleHandler: function(button, pressed) { > pressed ? InfoControl.activate() : InfoControl.deactivate() > } > > Where InfoControl would be the OpenLayers control to be > activated/deactivated. > > Best regards, > > Oscar. > > > > 2011/1/7 Vidal, Antoni <[email protected]>: >> Hello list, >> >> >> >> I trying to register a "mousedown" event to an action button but it doesn't >> work with the following code: >> >> >> >> action = new GeoExt.Action({ >> >> control: new OpenLayers.Control({eventListeners: >> {"mousedown": >> this.handleMousedown}}), >> >> tooltip: 'Info', >> >> map: map, >> >> iconCls: 'drawpolygon', >> >> toggleGroup: 'map' >> >> }); >> >> >> >> action.control.events.on({ >> >> "mousedown": handleMousedown >> >> }); >> >> >> >> actions.push(action); >> >> >> >> Any help would be appreciatte. >> >> >> >> Thanks >> >> >> >> Antoni Vidal >> >> Unitat d'Aplicacions SIG-WEB >> Institut Cartogràfic de Catalunya >> Parc de Montjuïc, E-08038 Barcelona >> Tel. (+34) 93 567 15 00 (ext. 3228) >> www.icc.cat >> >> >> >> _______________________________________________ >> Users mailing list >> [email protected] >> http://www.geoext.org/cgi-bin/mailman/listinfo/users >> >> > _______________________________________________ > Users mailing list > [email protected] > http://www.geoext.org/cgi-bin/mailman/listinfo/users > _______________________________________________ Users mailing list [email protected] http://www.geoext.org/cgi-bin/mailman/listinfo/users
