Changes

Jump to navigation Jump to search

D2Editor:setExpression

522 bytes added, 17:47, 18 June 2012
no edit summary
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>
      
This function sets the contents of a D2Editor, and is a synonym of setText.
 
This function sets the contents of a D2Editor, and is a synonym of setText.
Line 11: Line 10:  
== Example  ==
 
== Example  ==
   −
<source lang="lua">
+
<source lang="lua" highlight=9>
function on.create()
+
function on.construction() -- or on.create if OS 3.1
 
editor = D2Editor.newRichText()
 
editor = D2Editor.newRichText()
 
editor:move(0,0)
 
editor:move(0,0)
Line 19: Line 18:     
function on.charIn(char)
 
function on.charIn(char)
currentText = editor:getText()
+
currentText = editor:getExpression() -- or editor:getText()
editor:setText(currentText .. char)
+
editor:setExpression(currentText .. char) -- or editor:setText(...)
 
--Add char to the editor
 
--Add char to the editor
 
end
 
end
Line 30: Line 29:  
</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 :
 +
*\\0el {''content''} : Inserts a MathBox with the ''content'' inside it.
 +
 
 +
For example, '''editor:setExpression("\\1vector AB")''' will render as : http://i.imgur.com/aqVd8.jpg
    
== See also  ==
 
== See also  ==
 +
<categorytree mode=pages>D2Editor</categorytree>
   −
*[[D2Editor.getExpression]]()&nbsp;:
  −
*[[D2Editor.getExpressionSelection]]()&nbsp;:
  −
*[[D2Editor.isVisible]]()&nbsp;:
  −
*[[D2Editor.newRichText]]()&nbsp;:
  −
*[[D2Editor.resize]]()&nbsp;:
  −
*[[D2Editor.move]]()&nbsp;:
  −
*[[D2Editor.setFocus]]()&nbsp;:
  −
*[[D2Editor.setFontSize]]()&nbsp;:
  −
*[[D2Editor.setFormattedText]]()&nbsp;:
  −
*[[D2Editor.setMainFont]]()&nbsp;:
  −
*[[D2Editor.setReadOnly]]()&nbsp;:
      
[[Category:D2Editor]]
 
[[Category:D2Editor]]

Navigation menu