Line 1: |
Line 1: |
− | D2Editor:'''setExpression''' is a function that is part of the D2Editor Library. | + | __NOTOC__ |
| + | |
| + | |
| + | D2Editor:'''setExpression''' is a function that is part of the D2Editor Library. |
| | | |
| <br> | | <br> |
Line 19: |
Line 22: |
| | | |
| function on.charIn(char) | | function on.charIn(char) |
− | currentText = editor:getExpression() -- or getText() | + | currentText = editor:getExpression() -- or editor:getText() |
− | editor:setExpression(currentText .. char) -- or setText(...) | + | editor:setExpression(currentText .. char) -- or editor:setText(...) |
| --Add char to the editor | | --Add char to the editor |
| end | | end |
Line 30: |
Line 33: |
| </source> | | </source> |
| | | |
− | A very simple text editor (its actually more complicated that it be, but it shows the basics). | + | A very simple text editor (its actually more complicated, but it shows the basics). |
| + | |
| + | == Tips & Tricks == |
| + | |
| + | In order to insert some special template like MathBoxes, vectors shapes, angles etc., you have to put these in the '''setExpression''' argument : |
| + | *\\1angle : The text rendered inside is will be displayed under the "angle" shape |
| + | *\\1circle : Symbol for circle |
| + | *\\1keyword : |
| + | *\\1line : Symbol for line (parenthesis) |
| + | *\\1lineseg : Symbol for line segment |
| + | *\\1ray : |
| + | *\\1rtri : |
| + | *\\1subhead : |
| + | *\\1subscrp : Subscript text |
| + | *\\1supersc : Superscript text |
| + | *\\1title : |
| + | *\\1tri : Triangle symbol |
| + | *\\1vector : The text rendered inside is will be displayed under the vector arrow. |
| + | *\\1word : |
| + | |
| + | For example, '''editor:setExpression("\\1vector AB")''' will render as : <math>\overrightarrow{AB}</math> |
| + | |
| | | |
| == See also == | | == See also == |