[Users] Adding a menu item to an existing Tbar, not working
Andrew Stewart
Andrew.Stewart at reddeer.ca
Wed Oct 6 16:44:13 CEST 2010
Ah ok I think I had this backwards, I modified the example and I removed draw line/draw polyline from the bar and the menu still worked. However if I remove the other controls from the menu and leave only the polyline/line then I get the same result, the actions on the toolbar now don't toggle the actions on the menu even though they belong to the same togglegroup/group. So do I have to keep the actions from the toolbar inside the menu also for this to work? Below is my code of the modified example.
Ext.onReady(function() {
Ext.QuickTips.init();
var map = new OpenLayers.Map();
var wms = new OpenLayers.Layer.WMS(
"Global Imagery",
"http://maps.opengeo.org/geowebcache/service/wms",
{layers: "bluemarble"}
);
var vector = new OpenLayers.Layer.Vector("vector");
map.addLayers([wms, vector]);
var ctrl, toolbarItems = [], action, actions = {};
// ZoomToMaxExtent control, a "button" control
action = new GeoExt.Action({
control: new OpenLayers.Control.ZoomToMaxExtent(),
map: map,
text: "max extent",
tooltip: "zoom to max extent"
});
actions["max_extent"] = action;
toolbarItems.push(action);
toolbarItems.push("-");
// Navigation control and DrawFeature controls
// in the same toggle group
action = new GeoExt.Action({
text: "nav",
control: new OpenLayers.Control.Navigation(),
map: map,
// button options
toggleGroup: "draw",
allowDepress: false,
pressed: true,
tooltip: "navigate",
// check item options
group: "draw",
checked: true
});
actions["nav"] = action;
toolbarItems.push(action);
action = new GeoExt.Action({
text: "draw poly",
control: new OpenLayers.Control.DrawFeature(
vector, OpenLayers.Handler.Polygon
),
map: map,
// button options
toggleGroup: "draw",
allowDepress: false,
tooltip: "draw polygon",
// check item options
group: "draw"
});
actions["draw_poly"] = action;
action = new GeoExt.Action({
text: "draw line",
control: new OpenLayers.Control.DrawFeature(
vector, OpenLayers.Handler.Path
),
map: map,
// button options
toggleGroup: "draw",
allowDepress: false,
tooltip: "draw line",
// check item options
group: "draw"
});
actions["draw_line"] = action;
// SelectFeature control, a "toggle" control
action = new GeoExt.Action({
text: "select",
control: new OpenLayers.Control.SelectFeature(vector, {
type: OpenLayers.Control.TYPE_TOGGLE,
hover: true
}),
map: map,
// button options
enableToggle: true,
tooltip: "select feature"
});
actions["select"] = action;
toolbarItems.push(action);
toolbarItems.push("-");
// Navigation history - two "button" controls
ctrl = new OpenLayers.Control.NavigationHistory();
map.addControl(ctrl);
action = new GeoExt.Action({
text: "previous",
control: ctrl.previous,
disabled: true,
tooltip: "previous in history"
});
actions["previous"] = action;
toolbarItems.push(action);
action = new GeoExt.Action({
text: "next",
control: ctrl.next,
disabled: true,
tooltip: "next in history"
});
actions["next"] = action;
toolbarItems.push(action);
toolbarItems.push("->");
// Reuse the GeoExt.Action objects created above
// as menu items
toolbarItems.push({
text: "menu",
menu: new Ext.menu.Menu({
items: [
// Draw poly
new Ext.menu.CheckItem(actions["draw_poly"]),
// Draw line
new Ext.menu.CheckItem(actions["draw_line"]),
]
})
});
var mapPanel = new GeoExt.MapPanel({
renderTo: "mappanel",
height: 400,
width: 600,
map: map,
center: new OpenLayers.LonLat(5, 45),
zoom: 4,
tbar: toolbarItems
});
-----Original Message-----
From: Eric Lemoine [mailto:eric.lemoine at camptocamp.com]
Sent: October 05, 2010 10:57 PM
To: Andrew Stewart
Cc: users at geoext.org
Subject: Re: [Users] Adding a menu item to an existing Tbar, not working
On Tuesday, October 5, 2010, Andrew Stewart <Andrew.Stewart at reddeer.ca> wrote:
> So ya apparently the menu item must be on the toolbar as well for this to work.
It should not. The example just means to demonstrate that a
GeoExt.Action object can be used in multiple components.
--
Eric Lemoine
Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex
Tel : 00 33 4 79 44 44 96
Mail : eric.lemoine at camptocamp.com
http://www.camptocamp.com
[This message has been scanned for security content threats and viruses.]
[The City of Red Deer I.T. Services asks that you please consider the environment before printing this e-mail.]
More information about the Users
mailing list