| 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>text</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]] |