egui/crates/egui_glow
bu5hm4nn a2f1ca31a0
Add `ViewportCommand::RequestCut`, `RequestCopy` and `RequestPaste` to trigger Clipboard actions (#4035)
### Motivation
We want to offer our users a context menu with `Cut`, `Copy` and `Paste`
actions. `Paste` is not possible out of the box.

### Changes
This PR adds `ViewportCommand::RequestCut`,
`ViewportCommand::RequestCopy` and `ViewportCommand::RequestPaste`. They
are routed and handled after the example of
`ViewportCommand::Screenshot` and result in the same code being executed
as when the user uses `CTRL+V` style keyboard commands.

### Reasoning
In our last release we used an instance of
`egui_winit:📋:Clipboard` in order to get the `Paste`
functionality.

However Linux users on Wayland complained about broken clipboard
interaction (https://github.com/mikedilger/gossip/issues/617). After a
while of digging I could not find the issue although I have found
references to problems with multiple clipboards per handle before
(https://gitlab.gnome.org/GNOME/mutter/-/issues/1250) but I compared
mutter with weston and the problem occured on both.

So to solve this I set out to extend egui to access the clipboard
instance already present in egui_winit. Since there was no trivial way
to reach the instance of `egui_winit::State` I felt the best approach
was to follow the logic of the new `ViewportCommand::Screenshot`.

### Variations
It could make sense to make the introduced `enum ActionRequested` a part
of crates/egui/src/viewport.rs and to then wrap them into one single
`ViewportCommand::ActionRequest(ActionRequested)`.

### Example
```Rust
let mut text = String::new();
let response = ui.text_edit_singleline(&mut text);
if ui.button("Paste").clicked() {
    response.request_focus();
    ui.ctx().send_viewport_cmd(ViewportCommand::RequestPaste);
}
```

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2024-04-22 09:06:33 +02:00
..
examples Remove a bunch of `unwrap()` (#4285) 2024-03-30 19:33:19 +01:00
src Add `ViewportCommand::RequestCut`, `RequestCopy` and `RequestPaste` to trigger Clipboard actions (#4035) 2024-04-22 09:06:33 +02:00
CHANGELOG.md Release 0.27.2 - Fix blurry web rendering 2024-04-02 18:18:43 +02:00
Cargo.toml Update memoffset to 0.9.0, arboard to 3.3.1, and remove egui_glow's needless dependency on pure_glow's deps (#4036) 2024-02-13 10:32:18 +01:00
README.md Fix typo in `crates/egui_glow/README.md` (#2956) 2024-01-07 16:31:34 +01:00

README.md

egui_glow

Latest version Documentation MIT Apache

This crates provides bindings between egui and glow which allows you to:

  • Render egui using glow on both native and web.
  • Write cross platform native egui apps (with the winit feature).

To write web apps using glow you can use eframe (which uses egui_glow for rendering).

To use on Linux, first run:

sudo apt-get install libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libxkbcommon-dev libssl-dev

This crate optionally depends on egui-winit.

Test the example with:

cargo run -p egui_glow --example pure_glow --features=winit,egui/default_fonts