[OpenLayers-Users] Toolbar alternatives

Tim Schaub tschaub at openplans.org
Wed Nov 28 12:36:28 EST 2007


Hey-

Steve Lime wrote:
> Greetings: Has anyone developed alternatives to the basic toolbar controls that are part
> of OpenLayers? I'm interested in 2 or 3 state tools, being able to enable/disable tools, context
> sensitive help (e.g. "use this to ..."), being able to easily swap icon sets. Stuff like that.
> 
> Or can the Panel class be used to do all that? I didn't see a basic button/tool control that would
> be added to a panel in the docs so I wasn't sure.
> 

I think you got this answer already - but I wanted to add that I agree 
that you should push the Control.Panel to do what you want.

If you store a reference to a control, you can always call 
activate/deactivate on it.

If that control is part of a panel, call panel.activateControl(control). 
  If that control is TYPE_BUTTON, it's trigger method will be called.
If that control is TYPE_TOGGLE, it will be switched active/inactive 
depending on its current state.
Otherwise (TYPE_TOOL), the control will be activated and all other tool 
type controls on the panel will be deactivated (one TYPE_TOOL control 
active per panel).

The idea was that the panel class could be used to nest panels, giving 
you menus or nested toolbars/panels.

You get your third state (hover) and icons from CSS.  This is not 
perfect (in IE) and somewhat "hard" - largely due to poor docs.  But, I 
think all that you want can be done.

There is certainly room for improvement in the panel class - 
Chris/Schuyler wrote it in about 20 minutes as we sat around Chris' 
dinner table at about 3am one morning - but the idea is sound.

In particular, you might find it handy to have accessor methods for the 
controls in a panel (get controls by type, by name, by state, etc.). 
I'd like to do this in a more generic way (see the patch for ticket 1153 
if you're interested).  Just as it would be handy to be able to get 
collections (of layers or controls) on a map based on arbitrary 
criteria, the same would be nice on a panel (or a vector layer - with 
features for example).  When that ticket makes it through the review 
queue, if the idea has any traction, I'll apply the same to the control 
panel (and a few other places).

Anyway, if you find shortcomings in the panel class (bugs or otherwise), 
create tickets - I'd like to see it made more useful and I'm happy to 
write patches.

Tim

> Thanks- Steve
> 
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
> 
> !DSPAM:4033,474c8b11270181431913854!
> 




More information about the Users mailing list