-
Notifications
You must be signed in to change notification settings - Fork 1
Methods and Properties
Airhogs777 edited this page Jul 23, 2016
·
18 revisions
sb3-theme will store itself in a global object called sb3theme
. So, to access its methods and properties, you'll write things like sb3theme.horizontal
.
Name | Returns | Description | Example |
---|---|---|---|
sb3theme.style(string) |
Void |
add some CSS style to a style tag I've created just for you. | example |
sb3theme.onLoad(function() {}) |
Void |
runs when the Blockly workspace is initialized. | |
sb3theme.onNew(function(name, block, classes, blockData) {}) |
Void |
add a function that will run every time a new block is added. name is the block's official name within Scratch, block is the SVG group, classes are the classes that sb3theme has added to the block, and blockData is Blockly's internal data about the block. |
example |
sb3theme.onChange(function(name, block, classes, blockData) {}) |
Void |
add a function that will run every time a block's shape changes (including when it's first rendered). name is the block's official name within Scratch, block is the SVG group, classes are the classes that sb3theme has added to the block, and blockData is Blockly's internal data about the block. |
example |
sb3theme.addFilter(string) |
Void |
add a filter to the <defs> area of the SVG. Input should be a string containing an entire <filter> tag and its contents. If the SVG isn't initialized yet, it'll wait until it is. |
example |
-
sb3theme.css
- for your convenience, a<style>
tag to add your styles to usingsb3theme.style()
. -
sb3theme.options.menuColors
- true by default. If true, dropdown menus automatically have the background and border color of the block that created them.
None of the following properties can be accessed immediately when sb3-theme is initialized. You can access them from within an onLoad, onNew or onChange function:
-
sb3theme.horizontal
- true if you're in horizontal mode. -
sb3theme.colors
- an alias forBlockly.Colours
. Modifying these colors changes all blocks created going forward. -
sb3theme.svg
- the<svg>
element in which the editor is housed. -
sb3theme.NS
- the SVG's namespace. Useful for creating new elements viacreateElementNS