Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

egui_winit: Make the clipboard_text and allow_ime state public #3724

Merged
merged 6 commits into from
Jan 23, 2024
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions crates/egui-winit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,26 @@ impl State {
self.egui_input.max_texture_side = Some(max_texture_side);
}

/// Fetches text from the clipboard and returns it.
pub fn clipboard_text(&mut self) -> Option<String> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we document why this is mutable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH it's something deep down inside arboard (not sure about smithay), and it isn't obviously documented there other than it being "and get operation" and doing any operation probably requiring mut access.

self.clipboard.get()
}

/// Places the text onto the clipboard.
pub fn set_clipboard_text(&mut self, text: String) {
self.clipboard.set(text)
}

/// Returns [`false`] or the last value that [`Window::set_ime_allowed()`] was called with, used for debouncing.
pub fn allow_ime(&self) -> bool {
tosti007 marked this conversation as resolved.
Show resolved Hide resolved
self.allow_ime
}

/// Set the last value that [`Window::set_ime_allowed()`] was called with.
pub fn set_allow_ime(&mut self, allow: bool) {
self.allow_ime = allow;
}

#[inline]
pub fn egui_ctx(&self) -> &egui::Context {
&self.egui_ctx
Expand Down
Loading