Canvas Nasal API: Difference between revisions

Jump to navigation Jump to search
No edit summary
Line 276: Line 276:
== Text ==
== Text ==
Inherits from Element.
Inherits from Element.
=== enableUpdate ===
Enables the updateText() method for a text element.


=== setText ===
=== setText ===
Line 281: Line 286:


Sets the text to be displayed.
Sets the text to be displayed.
=== updateText ===
'''Parameters:''' (text)
The setText method internally writes the text string into a property node. If the method is run inside an update loop (as usually done for displays), setText writes the property regardless of whether the text has actually changed in the last update cycle. For complicated displays, this may cause a lot of unnecessary property I/O slowing down the simulation.
To improve this, updateText() keeps a Nasal variable record of the last text that has been written and writes the property only if the text has changed. Since this record needs to be allocated, the method requires to call enableUpdate() once before using it.
Note also that updateText() and setText() should not be both used on the same text element (updateText() will not register any changes made to the property string by any other means).
=== setAlignment ===
=== setAlignment ===
'''Parameters:''' (alignment)
'''Parameters:''' (alignment)
Line 342: Line 358:


Sets the color the text background should be drawn in.
Sets the color the text background should be drawn in.
== Path ==
== Path ==
Inherits from Element.
Inherits from Element.
1,360

edits

Navigation menu