Howto:Clipboard access using Nasal

From FlightGear wiki
Jump to navigation Jump to search
This has been nominated for deletion since 16 November 2024. To discuss it, please visit the talk page.

Do not remove this tag until the discussion is closed.


Reason for the nomination: This article either contains out of date information, and/or may not meet the quality standards of the wiki, potentially to the point of causing confusion or frustration to readers.


This article is a stub. You can help the wiki by expanding it.

As of 08/2012 (i.e. in upcoming FlightGear 3.0), there's a "clipboard" hash in Nasal space which can be used to access the clipboard. There are two types of clipboards supported:

  • CLIPBOARD: Standard clipboard like on almost everything operating system
  • SELECTION: Primary X Selection like found on X11 based systems. On non-X11 platform this clipboard is only accessible from inside FlightGear.
# Setting/getting the contents of the given type of clipboard. If
# 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

Some examples of using the clipboard:

print("Clipboard contains: ", clipboard.getText() );
print("Selection contains: ", clipboard.getText(clipboard.SELECTION) );

if( !clipboard.setText("test") )
  print("Failed to write to clipboard");
if( !clipboard.setText("test-selection", clipboard.SELECTION) )
  print("Failed to write to selection");