Documentation | ApplicationKit | Clipboard
SYNOPSIS
Perl
use HaikuR1::Clipboard qw(B_CLIPBOARD_CHANGED); my $clipboard = HaikuR1::Clipboard->new($name); $clipboard->Lock(); my $message = $clipboard->Data(); # change contents of message $clipboard->Commit(); $clipboard->Unlock();
Python
from HaikuR1.ApplicationKit import Clipboard, B_CLIPBOARD_CHANGED clipboard = Clipboard(name) clipboard->Lock() message = clipboard->Data() # change contents of message clipboard->Commit() clipboard->Unlock()
DESCRIPTION
Exposes the BClipboard
object.
For more information on Clipboard, see the Be Book class description, the Be Book overview, and the Haiku Book class description.
METHODS
Constructor
Creates a Clipboard object attached to a named clipboard.
Perl
HaikuR1::Clipboard->new($name, $discard);
Python
Clipboard(name, discard)
name
A native string, the name of the clipboard; a new clipboard is created if one with that name does not already exist.
discard
A boolean, currently unused.
Clear
Clears the Clipboard object's data.
Perl
$clipboard->Clear();
Python
clipboard.Clear()
Commit
Writes the Clipboard object's data to the underlying clipboard.
Perl
$clipboard->Commit($failIfChanged);
Python
clipboard.Commit(failIfChanged)
failIfChanged
A boolean, if true, the commit will fail if the clipboard has changed; defaults to false.
Count
LocalCount
SystemCount
LocalCount
fetches a cached count of the number of commits to the clipboard.
SystemCount
fetches the value from the system.
Perl
$clipboard->LocalCount(); $clipboard->SystemCount();
Python
clipboard.LocalCount() clipboard.SystemCount()
Data
Returns the Message object that holds the clipboard data, or the empty value if the Clipboard object is not locked.
Perl
$clipboard->Data();
Python
clipboard.Data()
DataSource
Returns a Messenger that targets the application that last wrote to the Clipboard.
Perl
$clipboard->DataSource();
Python
clipboard.DataSource()
Locking
Lock
Unlock
IsLocked
These functions do what you expect. The Clipboard must be locked before reading or writing data.
Lock
blocks if the Clipboard is already locked. It returns true if the lock
was successful, false if the Clipboard was deleted while waiting for a lock.
Perl
$clipboard->Lock(); $clipboard->Unlock(); $clipboard->IsLocked();
Python
clipboard.Lock() clipboard.Unlock() clipboard.IsLocked()
Name
Returns the name of the clipboard.
Perl
$clipboard->Name();
Python
clipboard.Name()
Notifications
StartWatching
StopWatching
Begins or stops watching for changes in the clipboard.
Perl
$clipboard->StartWatching($target); $clipboard->StopWatching($target);
Python
clipboard.StartWatching(target) clipboard.StopWatching(target)
target
A Messenger, the target; a
B_CLIPBOARD_CHANGED
message will be sent to the Messenger's target when the clipboard changes.
Revert
Reloads data from the underlying clipboard, losing any data in the Clipboard object.
Perl
$clipboard->Revert();
Python
clipboard.Revert()
CONSTANTS
B_CLIPBOARD_CHANGED
Sent when a clipboard changes, to any targets that have requested change notifications for that clipboard.
GLOBALS
be_clipboard
The system clipboard.