[Users] Dynamic toolbar buttons for vector editing - how?

Matt Priour mpriour at kestrelcomputer.com
Tue Sep 28 23:26:46 CEST 2010


Control & map properites are important during the intialization and 
construction phase of the button components. However to interactively 
disable the buttons in response to another event, you need to locate the 
button and call its disable() function.

For example:
/* some GeoExt action or button config */
{ id:'myBtn',
disabled:true,
enableToggle:true,
toggleGroup:'map',
control: someMapControl
}

The disable/enable process for the button can be controled by the layer or 
the radio button.
If you are using a treeloader to populate your tree (ie via an 
OverlayLayerContianer node type), then attaching it to the layer's 
visibility changed event makes more sense.

/* using a layer */
var myVectorLayer = new OpenLayers.Layer.Vector('my vector',{
   eventListeners:{
      'visibilitychanged':function(evt){
        var btn = Ext.getCmp('myBtn');
        if(evt.object.visibility){
            btn.enable();
        }
        else{
            btn.disable();
        }
      }
    }
})

Matt Priour
Kestrel Computer Consulting

--------------------------------------------------
From: "David E. Reksten" <der at dod.no>
Sent: Tuesday, September 28, 2010 2:31 PM
To: <users at geoext.org>
Subject: [Users] Dynamic toolbar buttons for vector editing - how?

> Hi,
>
> I have an application where users can add one or many vector layers to
> the base map. I have a treePanel with radio buttons that lets the
> users activate one of their vector layers. This works very well.
>
> When a layer is activated, I want to enable a couple of buttons on the
> toolbar (bbar on the mapPanel) to allow drawing and editing polygons.
> When there are no user defined vector layers available (ie., none
> selected), I want the buttons to either disappear or to be disabled.
> What is the best strategy for this?
>
> I have tried to set up "dummy" buttons on the toolbar and dynamically
> set their "control" and "map" properties when the selected vector
> layer changes, but cannot get it to work.
>
> Regards,
> .david
>
> PS: Big thanks to the GeoExt team for all the hard work and congrats
> for v1rc1 :-)
> _______________________________________________
> Users mailing list
> Users at geoext.org
> http://www.geoext.org/cgi-bin/mailman/listinfo/users 



More information about the Users mailing list