Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

context.document is undefined for some actions so it breaks the API #48

Closed
cameronmcefee opened this issue Mar 19, 2017 · 2 comments
Closed
Labels
bug Confirmed bugs or reports that are very likely to be bugs

Comments

@cameronmcefee
Copy link

cameronmcefee commented Mar 19, 2017

In the manifest commands:

 "script": "myscript.js",
"handlers": {
  "actions": {
    "SelectionChanged.finish": "onSelectionChanged"
  }
}

in myscript.js

var onSelectionChanged = function(context) {
  var sketch = context.api()

  log(sketch.api_version)
  log(sketch.version)
  log(sketch.build)
  log(sketch.full_version)

  var document = sketch.selectedDocument;
  log(document.selectedLayers);
}

When changing selection:

TypeError: null is not an object (evaluating 'this._object.currentPage')
line: 810
sourceURL: /Applications/Sketch.app/Contents/Resources/SketchAPI.js
column: 41

Looks like the code in question is:

{
  key: 'selectedPage',
  get: function get() {
    return new _Page.Page(this._object.currentPage(), this);
  }
}
@mathieudutour mathieudutour added the bug Confirmed bugs or reports that are very likely to be bugs label Dec 14, 2017
@mathieudutour mathieudutour changed the title Getting selected layers appears to be broken. context.document is undefined for some actions so it breaks the API Dec 14, 2017
@DanielRuf
Copy link

DanielRuf commented Feb 1, 2018

It also seems the readme is not up to date.

@mathieudutour
Copy link
Contributor

the readme is up to date with the develop branch which is not released yet

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Confirmed bugs or reports that are very likely to be bugs
Projects
None yet
Development

No branches or pull requests

4 participants