Skip to main content

PrimarySelectionExt

Trait PrimarySelectionExt 

Source
pub trait PrimarySelectionExt: Debug {
    // Required methods
    fn primary_selection(&self) -> Result<Option<DataTransferId>, TransferError>;
    fn set_primary_selection(
        &self,
        send_data: Box<dyn DataTransferSend>,
    ) -> Result<(), TransferError>;
}
Expand description

Platform extension allowing access to the primary selection, where available.

The primary selection is a separate clipboard on Wayland and X11, usually holding the most recently selected text and pasted with a middle click.

Access via ActiveEventLoop::primary_selection_ext.

§Example

ⓘ
if let Some(ext) = event_loop.primary_selection_ext() {
    if let Some(data_transfer_id) = ext.primary_selection()? {
        event_loop.fetch_data_transfer(data_transfer_id, &TypeHint::Plaintext)?;
    }
}

Required Methods§

Source

fn primary_selection(&self) -> Result<Option<DataTransferId>, TransferError>

Get the current primary selection contents as a data transfer, or None if the primary selection is empty.

See ActiveEventLoop::clipboard for more details.

Source

fn set_primary_selection( &self, send_data: Box<dyn DataTransferSend>, ) -> Result<(), TransferError>

Set the primary selection contents.

See ActiveEventLoop::set_clipboard for more details.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§