Skip to content

Instantly share code, notes, and snippets.

@bomberstudios
Last active August 29, 2015 14:22
Show Gist options
  • Save bomberstudios/fa0d5c299b09d65d9259 to your computer and use it in GitHub Desktop.
Save bomberstudios/fa0d5c299b09d65d9259 to your computer and use it in GitHub Desktop.
// Move Right 100px (shift option →)
function areWeEditingText(){
var currentLayer = context.selection[0]
if (currentLayer == null || currentLayer.isEditingText == undefined) {
return false
} else {
return currentLayer.isEditingText()
}
}
if(areWeEditingText()) {
// Do nothing, since we're editing text
} else {
// Move selected layer
var x = context.selection[0].frame().x()
context.selection[0].frame().setX(x + 100)
}
@ricburton
Copy link

Unfortunately I couldn’t get that script to run or move anything. I changed the moving code a bit to the same stuff as Sketch Commands. Every time I try and run the plugin when I’m editing a text layer the Plugins dropdown flashes and nothing happens.

http://cl.ly/0b1H2d1n0p1a

// Move Right 100px (shift option →)
function areWeEditingText(){    
  var currentLayer = context.selection[0]
  if (currentLayer == null || currentLayer.isEditingText == undefined) {
    return false
  } else {
    return currentLayer.isEditingText()
  }
}

if(areWeEditingText()) {
  // Do nothing, since we're editing text
} else {
  // Move all selected layers
  for (var i=0; i < [selection count]; i++) {
      var layer = [selection objectAtIndex:i]
      var x = layer.frame().x()
      layer.frame().x = (x+100)
    }   
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment