Fixup area drawing, add delete keybinding for deleting last point

This commit is contained in:
Tom MacWright
2012-12-05 16:44:45 -05:00
parent cbb49d2322
commit aa066ec8b2
2 changed files with 28 additions and 4 deletions
+14 -2
View File
@@ -24,9 +24,10 @@ iD.modes.DrawArea = function(way_id) {
if (datum.type === 'node') {
if (datum.id == firstnode_id) {
mode.history.replace(iD.actions.DeleteNode(node));
mode.history.replace(iD.actions.addWayNode(way,
mode.history.graph().entity(way.nodes[0])));
way = mode.history.graph().entity(way.id);
mode.history.perform(iD.actions.changeTags(way, _.omit(way.tags, 'elastic')));
// End by clicking on own tail
@@ -45,6 +46,16 @@ iD.modes.DrawArea = function(way_id) {
mode.map.keybinding().on('⎋.drawarea', function() {
mode.controller.exit();
})
.on('⌫.drawarea', function() {
d3.event.preventDefault();
var lastNode = _.last(way.nodes);
mode.history.replace(iD.actions.removeWayNode(way,
mode.history.graph().entity(lastNode)));
mode.history.replace(iD.actions.DeleteNode(
mode.history.graph().entity(lastNode)));
mode.history.replace(iD.actions.DeleteNode(node));
mode.controller.enter(iD.modes.DrawArea(way_id));
});
};
@@ -53,7 +64,8 @@ iD.modes.DrawArea = function(way_id) {
mode.map.surface
.on('mousemove.drawarea', null)
.on('click.drawarea', null);
mode.map.keybinding().on('⎋.drawarea', null);
mode.map.keybinding().on('⎋.drawarea', null)
.on('⌫.drawarea', null);
window.setTimeout(function() {
mode.map.dblclickEnable(true);
}, 1000);
+14 -2
View File
@@ -17,7 +17,8 @@ iD.modes.DrawRoad = function(way_id, direction) {
mode.history.perform(iD.actions.addWayNode(way, node, index));
mode.map.surface.on('mousemove.drawroad', function() {
mode.history.replace(iD.actions.addWayNode(way, node.update({loc: mode.map.mouseCoordinates()}), index));
mode.history.replace(iD.actions.addWayNode(way,
node.update({loc: mode.map.mouseCoordinates()}), index));
});
mode.map.surface.on('click.drawroad', function() {
@@ -63,6 +64,16 @@ iD.modes.DrawRoad = function(way_id, direction) {
mode.map.keybinding().on('⎋.drawroad', function() {
mode.controller.exit();
});
mode.map.keybinding().on('⌫.drawroad', function() {
d3.event.preventDefault();
mode.history.replace(iD.actions.removeWayNode(way,
mode.history.graph().entity(lastNode)));
mode.history.replace(iD.actions.DeleteNode(
mode.history.graph().entity(lastNode)));
mode.history.replace(iD.actions.DeleteNode(node));
mode.controller.enter(iD.modes.DrawRoad(way_id, direction));
});
};
mode.exit = function() {
@@ -70,7 +81,8 @@ iD.modes.DrawRoad = function(way_id, direction) {
mode.map.surface
.on('mousemove.drawroad', null)
.on('click.drawroad', null);
mode.map.keybinding().on('⎋.drawroad', null);
mode.map.keybinding().on('⎋.drawroad', null)
.on('⌫.drawroad', null);
window.setTimeout(function() {
mode.map.dblclickEnable(true);
mode.map.dragEnable(true);