Reopen radial menu when clicking on selected entity (fixes #758)

This commit is contained in:
John Firebaugh
2013-02-13 16:23:58 -08:00
parent 372e009888
commit c0b8cd74de
2 changed files with 31 additions and 10 deletions

View File

@@ -8,9 +8,11 @@ iD.behavior.Select = function(context) {
} else if (!d3.event.shiftKey) {
// Avoid re-entering Select mode with same entity.
if (context.selection().length !== 1 || context.selection()[0] !== datum.id)
if (context.selection().length !== 1 || context.selection()[0] !== datum.id) {
context.enter(iD.modes.Select(context, [datum.id]));
} else {
context.mode().reselect();
}
} else if (context.selection().indexOf(datum.id) >= 0) {
var selection = _.without(context.selection(), datum.id);
context.enter(selection.length ?

View File

@@ -28,10 +28,31 @@ iD.modes.Select = function(context, selection, initial) {
}
}
function positionMenu() {
var entity = singular();
if (entity && entity.type === 'node') {
radialMenu.center(context.projection(entity.loc));
} else {
radialMenu.center(d3.mouse(context.surface().node()));
}
}
function showMenu() {
context.surface()
.call(radialMenu.close)
.call(radialMenu);
}
mode.selection = function() {
return selection;
};
mode.reselect = function() {
positionMenu();
showMenu();
};
mode.enter = function() {
var entity = singular();
@@ -166,18 +187,16 @@ iD.modes.Select = function(context, selection, initial) {
.classed('selected', true);
radialMenu = iD.ui.RadialMenu(operations);
var showMenu = d3.event && !initial;
var show = d3.event && !initial;
if (showMenu) {
if (entity && entity.type === 'node') {
radialMenu.center(context.projection(entity.loc));
} else {
radialMenu.center(d3.mouse(context.surface().node()));
}
if (show) {
positionMenu();
}
timeout = window.setTimeout(function() {
if (showMenu) context.surface().call(radialMenu);
if (show) {
showMenu();
}
context.surface()
.on('dblclick.select', dblclick);