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 aa76f7b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 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
2 changes: 1 addition & 1 deletion src/systems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub struct InputResources<'w, 's> {
#[cfg(all(feature = "manage_clipboard", target_arch = "wasm32"))]
pub egui_clipboard: ResMut<'w, crate::EguiClipboard>,
#[cfg(all(feature = "manage_clipboard", not(target_arch = "wasm32")))]
pub egui_clipboard: Res<'w, crate::EguiClipboard>,
pub egui_clipboard: ResMut<'w, crate::EguiClipboard>,
pub keyboard_input: Res<'w, Input<KeyCode>>,
#[system_param(ignore)]
_marker: PhantomData<&'s ()>,
Expand Down

0 comments on commit aa76f7b

Please sign in to comment.