166
edits
| Line 174: | Line 174: | ||
BTW: There is already a property to toggle the mouse cursor via setprop, so this could also be wrapped in gui.nas, obviously being able to use a canvas texture as the cursor would prove the point that "everything is a canvas" in the design. | BTW: There is already a property to toggle the mouse cursor via setprop, so this could also be wrapped in gui.nas, obviously being able to use a canvas texture as the cursor would prove the point that "everything is a canvas" in the design. | ||
=== Multiplatform Clipboard Support (native Copy/Paste) {{Pending}} === | === Multiplatform Clipboard Support (native Copy/Paste) {{Pending}} === | ||
{{Progressbar| | {{Progressbar|70}} | ||
Needs to be individually implemented for each supported window manager environment (Windows, OSX, X11): | Needs to be individually implemented for each supported window manager environment (Windows, OSX, X11): | ||
* X11: [https://gitorious.org | * X11: [https://gitorious.org/fg/flightgear/blobs/next/src/Scripting/ClipboardX11.cxx Scripting/ClipboardX11.cxx] {{Done}} | ||
* Windows: [https://gitorious.org | * Windows: [https://gitorious.org/fg/flightgear/blobs/next/src/Scripting/ClipboardWindows.cxx Scripting/ClipboardWindows.cxx] {{Done}} | ||
* OSX: To be based on: [https://gitorious.org | * OSX: To be based on: [https://gitorious.org/fg/flightgear/blobs/next/src/Scripting/ClipboardFallback.cxx Scripting/ClipboardFallback.cxx] {{Not done}} | ||
* '''Hooray''': "Also, copy/paste usually involves getting a bounding box for the area and retrieving the text in that area (drawing a rectangle and inverting the font color)" | * '''Hooray''': "Also, copy/paste usually involves getting a bounding box for the area and retrieving the text in that area (drawing a rectangle and inverting the font color)" | ||
| Line 199: | Line 188: | ||
* f_getClipboardText() {{Done}} | * f_getClipboardText() {{Done}} | ||
==== Nasal API ==== | |||
In Nasal space, there exists a "clipboard" hash which can be used to access the clipboard. There are two types of clipboards supported: | In Nasal space, there exists a "clipboard" hash which can be used to access the clipboard. There are two types of clipboards supported: | ||
* CLIPBOARD: Standard clipboard like on almost everything operating system | * CLIPBOARD: Standard clipboard like on almost everything operating system | ||
* SELECTION | * SELECTION: Primary X Selection like found on X11 based systems. On non-X11 platform this clipboard is only accessible from inside FlightGear. | ||
<syntaxhighlight lang="php"> | <syntaxhighlight lang="php"> | ||
clipboard.setText(text, type = | # Setting/getting the contents of the given type of clipboard. If | ||
clipboard.getText(type = | # no type is specified it defaults to the standard clipboard. | ||
# The return value indicates whether the operation completed | |||
# successfully. | |||
clipboard.setText: func(text, type = clipboard.CLIPBOARD) : bool | |||
clipboard.getText: func(type = clipboard.CLIPBOARD) : bool | |||
</syntaxhighlight> | |||
Some examples of using the clipboard: | |||
<syntaxhighlight lang="php"> | |||
print("Clipboard contains: ", clipboard.getText() ); | print("Clipboard contains: ", clipboard.getText() ); | ||
print("Selection contains: ", clipboard.getText( | print("Selection contains: ", clipboard.getText(clipboard.SELECTION) ); | ||
if( !clipboard.setText("test") ) | if( !clipboard.setText("test") ) | ||
print("Failed to write to clipboard"); | print("Failed to write to clipboard"); | ||
if( !clipboard.setText("test-selection", | if( !clipboard.setText("test-selection", clipboard.SELECTION) ) | ||
print("Failed to write to selection"); | print("Failed to write to selection"); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
edits