This repository has been archived by the owner on Aug 31, 2021. It is now read-only.
[[ HTML5Callbacks ]] Allow specified LiveCode handlers to be called from JavaScript #5602
Merged
runrevmark
merged 8 commits into
livecode:develop
from
livecodeian:feature-html5-callback
Jun 14, 2017
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1f430f4
[[ HTMLCallback ]] Add library code to get list of stack javascript-v…
livecodeian 21be477
[[ HTML5Callbacks ]] Fix several bugs in JS->LiveCode interface
livecodeian 08fe9af
[[ HTML5Callbacks ]] use LiveCodeAsync.resume(...) to call from JS to…
livecodeian 8ec2520
[[ HTML5Callbacks ]] Fix bug when calling MCProperListPushElementOnto…
livecodeian 3f3cdb0
[[ HTML5Callbacks ]] Implement handler execution & function value return
livecodeian 1f2a4df
[[ HTM5Callbacks ]] add liveCode.findStackWithName to JS document object
livecodeian d66c708
[[ HTML5Callbacks ]] Rename javascripthandler custom property
livecodeian 93f1d75
[[ HTML5Callbacks ]] Add release note.
livecodeian File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# HTML5 Callbacks - enable calling handlers in LiveCode emscripten standalones from JavaScript | ||
|
||
**Note** This is still an experimental feature - details may change as development continues. | ||
|
||
## Stack setup | ||
|
||
Each stack can be configured to expose its handlers & functions to JavaScript. This is done through a custom property of the stack - `cJavascriptHandlers`. (This will be replaced in the future by a `javascriptHandlers` property which will then be a reserved keyword). The `cJavascriptHandlers` property is a return-delimited list of handler names. The named handlers do not have to be defined at the time the stack is loaded, however calling an undefined handler from JavaScript will result in an error. | ||
|
||
|
||
## Calling from JavaScript | ||
|
||
The standalone engine will create a `liveCode` object on the DOM `document` object. To this object will be attached the `findStackWithName` method that can be called to return a JavaScript stack object. Each stack object will have methods corresponding to the exposed handlers of that stack. For instance, a stack with the `cJavascriptHandlers` property set to : | ||
|
||
```performAction | ||
setProperty | ||
getProperty | ||
``` | ||
|
||
will have methods named accordingly, which when executed will call the corresponding handler with the provided arguments. | ||
|
||
## JavaScript Example: | ||
|
||
```var myStack = document.liveCode.findStackWithName(“HTMLTest”); | ||
var oldDocTitle = myStack.getProperty(‘documentTitle’); | ||
myStack.setProperty(‘documentTitle’, ‘Important Document’); | ||
myStack.performAction(‘sendEmail’); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest we make the name 'livecode' - I think liveCode will be prone to errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
liveCode is consistent with the naming in the browser widget, although the usage there is slightly different
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's fine - we'll keep it consistent for now - we can add an alias at a later date.