Fix Issue 29: Key bindings for moving selected, move to top/back, delete for Macbook users
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@186 eee81c28-f429-11dd-99c0-75d572ba1dddmaster
parent
016a3572c5
commit
35ad2d7841
|
@ -38,9 +38,9 @@
|
|||
<!-- Buttons when something is selected -->
|
||||
<div id="selected_panel">
|
||||
<img class="tool_sep" src="images/sep.png" alt="|"/>
|
||||
<img class="tool_button" id="tool_delete" src="images/delete.png" title="Delete Element [Delete]" alt="Delete"/>
|
||||
<img class="tool_button" id="tool_move_top" src="images/move_top.png" title="Move to Top [Page Up]" alt="Top"/>
|
||||
<img class="tool_button" id="tool_move_bottom" src="images/move_bottom.png" title="Move to Bottom [Page Down]" alt="Bottom"/>
|
||||
<img class="tool_button" id="tool_delete" src="images/delete.png" title="Delete Element [Delete/Backspace]" alt="Delete"/>
|
||||
<img class="tool_button" id="tool_move_top" src="images/move_top.png" title="Move to Top [Shift+Up]" alt="Top"/>
|
||||
<img class="tool_button" id="tool_move_bottom" src="images/move_bottom.png" title="Move to Bottom [Shift+Down]" alt="Bottom"/>
|
||||
</div>
|
||||
|
||||
<!-- TODO: also add x, y, width, height -->
|
||||
|
|
|
@ -37,7 +37,7 @@ function svg_edit_setup() {
|
|||
|
||||
// called when any element has changed
|
||||
var elementChanged = function(window,elem) {
|
||||
// if the element that changed was teh selected element, we
|
||||
// if the element that changed was the selected element, we
|
||||
// should update the contextual panel with potentially new
|
||||
// positional/sizing information (we DON'T want to update the
|
||||
// toolbar here as that creates an infinite loop)
|
||||
|
@ -273,6 +273,12 @@ function svg_edit_setup() {
|
|||
}
|
||||
}
|
||||
|
||||
var moveSelected = function(dx,dy) {
|
||||
if (selectedElement != null) {
|
||||
svgCanvas.moveSelectedElement(dx,dy);
|
||||
}
|
||||
}
|
||||
|
||||
var clickText = function(){
|
||||
toolButtonClick('#tool_text');
|
||||
svgCanvas.setMode('text');
|
||||
|
@ -333,9 +339,14 @@ function svg_edit_setup() {
|
|||
$(document).bind('keydown', {combi:'6', disableInInput: true}, clickText);
|
||||
$(document).bind('keydown', {combi:'N', disableInInput: true}, clickClear);
|
||||
$(document).bind('keydown', {combi:'S', disableInInput: true}, clickSave);
|
||||
$(document).bind('keydown', {combi:'del', disableInInput: true}, deleteSelected);
|
||||
$(document).bind('keydown', {combi:'pageup', disableInInput: true}, moveToTopSelected);
|
||||
$(document).bind('keydown', {combi:'pagedown', disableInInput: true}, moveToBottomSelected);
|
||||
$(document).bind('keydown', {combi:'del', disableInInput: true}, function(evt){deleteSelected();evt.preventDefault();});
|
||||
$(document).bind('keydown', {combi:'backspace', disableInInput: true}, function(evt){deleteSelected();evt.preventDefault();});
|
||||
$(document).bind('keydown', {combi:'shift+up', disableInInput: true}, moveToTopSelected);
|
||||
$(document).bind('keydown', {combi:'shift+down', disableInInput: true}, moveToBottomSelected);
|
||||
$(document).bind('keydown', {combi:'up', disableInInput: true}, function(evt){moveSelected(0,-1);evt.preventDefault();});
|
||||
$(document).bind('keydown', {combi:'down', disableInInput: true}, function(evt){moveSelected(0,1);evt.preventDefault();});
|
||||
$(document).bind('keydown', {combi:'left', disableInInput: true}, function(evt){moveSelected(-1,0);evt.preventDefault();});
|
||||
$(document).bind('keydown', {combi:'right', disableInInput: true}, function(evt){moveSelected(1,0);evt.preventDefault();});
|
||||
|
||||
var colorPicker = function(elem) {
|
||||
$('.tools_flyout').hide();
|
||||
|
|
|
@ -973,6 +973,18 @@ function SvgCanvas(c)
|
|||
t.parentNode.insertBefore(t, t.parentNode.firstChild);
|
||||
}
|
||||
}
|
||||
|
||||
this.moveSelectedElement = function(dx,dy) {
|
||||
if (selected != null) {
|
||||
// TODO: move...
|
||||
selectedBBox = selected.getBBox();
|
||||
selectedBBox.x += dx;
|
||||
selectedBBox.y += dy;
|
||||
|
||||
recalculateSelectedDimensions();
|
||||
recalculateSelectedOutline();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue