Difference between revisions of "clipboard.addText"

From Inspired-Lua Wiki
Jump to navigation Jump to search
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
clipboard.'''addText''' is a function that is part of the Clipboard Library.  
+
clipboard.'''addText''' is a function that is part of the [[:Category:clipboard|clipboard]] functions.  
  
 
<br>  
 
<br>  
 +
The function sets the content of the clipboard, so it can be pasted somewhere else. <br>
 +
<br />
  
The function sets the content of the clipboard. <br>
+
{{Since|3.0}}
 
 
It accepts a string as input.<br>
 
  
 
== Syntax  ==
 
== Syntax  ==
  
clipboard.'''addText'''(string)  
+
clipboard.'''addText'''(text)  
  
 
{| class="wikitable"
 
{| class="wikitable"
 
|-
 
|-
! Parameter  
+
! Parameter
 +
! Type
 
! Description
 
! Description
 
|-
 
|-
| <u>string</u>  
+
| <u><center>text</center></u>  
| String that you want to add to clipboad
+
| string
 +
| The text you want to add to the clipboard
 
|}
 
|}
  
 
== Example  ==
 
== Example  ==
  
<source lang="lua">--Clipboard test
+
<source lang="lua">--Clipboard test : Setting "Hello" in the clipboard and displaying it.
  
 
function on.paint(gc)
 
function on.paint(gc)
clip = clipboard.getText()
+
text = clipboard.getText()
gc:drawString(clip, 100, 100)
+
gc:drawString(text, 100, 100, "top")
 
end
 
end
  
function on.charIn(ch)
+
function on.enterKey() -- event that fires when the user presses the enter key.
clipboard.addText(ch)
+
clipboard.addText("Hello")
platform.window:invalidate() -- recall graph engine
+
platform.window:invalidate() -- recall graph engine, i.e. call on.paint(gc)
 
end</source>  
 
end</source>  
  
This code will read the content of the clipboard and print it on the screen. When you press a key, it will put the key value in the clipboard.  
+
This code will read the content of the clipboard and print it on the screen. When you press the enter key, it will put "Hello" in the clipboard.  
  
 
== See also  ==
 
== See also  ==
 
 
*[[clipboard.getText|clipboard.getText]]
 
*[[clipboard.getText|clipboard.getText]]
  
[[Category:clipboard|C]]
+
[[Category:clipboard]]

Latest revision as of 23:44, 30 May 2011

clipboard.addText is a function that is part of the clipboard functions.


The function sets the content of the clipboard, so it can be pasted somewhere else.

This has been introduced in TI-Nspire OS 3.0 (Changes).


Syntax

clipboard.addText(text)

Parameter Type Description
text
string The text you want to add to the clipboard

Example

--Clipboard test : Setting "Hello" in the clipboard and displaying it.

function on.paint(gc)
	text = clipboard.getText()
	gc:drawString(text, 100, 100, "top")
end

function on.enterKey() -- event that fires when the user presses the enter key.
	clipboard.addText("Hello")
	platform.window:invalidate() -- recall graph engine, i.e. call on.paint(gc)
end

This code will read the content of the clipboard and print it on the screen. When you press the enter key, it will put "Hello" in the clipboard.

See also