Skip to content

Commit

Permalink
unified mut api for clipboard
Browse files Browse the repository at this point in the history
  • Loading branch information
Vrixyz committed May 31, 2023
1 parent 9032a4e commit ea933e7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ impl EguiClipboard {
/// Gets clipboard contents. Returns [`None`] if clipboard provider is unavailable or returns an error.
#[must_use]
#[cfg(not(target_arch = "wasm32"))]
pub fn get_contents(&self) -> Option<String> {
pub fn get_contents(&mut self) -> Option<String> {
self.get_contents_impl()
}

Expand All @@ -185,12 +185,12 @@ impl EguiClipboard {
}

#[cfg(target_arch = "wasm32")]
fn set_contents_impl(&self, contents: &str) {
fn set_contents_impl(&mut self, contents: &str) {
web_clipboard::clipboard_copy(contents.to_owned());
}

#[cfg(not(target_arch = "wasm32"))]
fn get_contents_impl(&self) -> Option<String> {
fn get_contents_impl(&mut self) -> Option<String> {
if let Some(mut clipboard) = self.get() {
match clipboard.get_text() {
Ok(contents) => return Some(contents),
Expand Down
4 changes: 1 addition & 3 deletions src/systems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,8 @@ impl<'w, 's> InputEvents<'w, 's> {
#[allow(missing_docs)]
#[derive(SystemParam)]
pub struct InputResources<'w, 's> {
#[cfg(all(feature = "manage_clipboard", target_arch = "wasm32"))]
#[cfg(feature = "manage_clipboard")]
pub egui_clipboard: ResMut<'w, crate::EguiClipboard>,
#[cfg(all(feature = "manage_clipboard", not(target_arch = "wasm32")))]
pub egui_clipboard: Res<'w, crate::EguiClipboard>,
pub keyboard_input: Res<'w, Input<KeyCode>>,
#[system_param(ignore)]
_marker: PhantomData<&'s ()>,
Expand Down

0 comments on commit ea933e7

Please sign in to comment.