Skip to content

Commit

Permalink
Fix incorrect cursor icon on copy button
Browse files Browse the repository at this point in the history
  • Loading branch information
lampsitter committed Apr 2, 2024
1 parent 0f84f54 commit 930a5c5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,22 @@

- Replace copy icon with checkmark when clicking copy button in code blocks
([#42](https://github.com/lampsitter/egui_commonmark/pull/42) by [@zeozeozeo](https://github.com/zeozeozeo))

- Interactive tasklists with `CommonMarkViewer::show_mut`
([#40](https://github.com/lampsitter/egui_commonmark/pull/40) by [@crumblingstatue](https://github.com/crumblingstatue))

### Changed

- Alerts are case-insensitive
- More spacing between list indicator and elements ([#46](https://github.com/lampsitter/egui_commonmark/pull/46)
- More spacing between list indicator and elements ([#46](https://github.com/lampsitter/egui_commonmark/pull/46))

### Fixed

- Lists align text when wrapping instead of wrapping at the beginning of the next
line ([#46](https://github.com/lampsitter/egui_commonmark/pull/46)
line ([#46](https://github.com/lampsitter/egui_commonmark/pull/46))
- Code blocks won't insert a newline when in lists
- In certain scenarios there was no newline after lists
- Copy button for code blocks show the correct cursor again on hover (regression
after egui 0.27)

## 0.14.0 - 2024-03-26

Expand Down
29 changes: 19 additions & 10 deletions src/elements.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,16 +120,25 @@ pub fn code_block<'t>(
let persistent_id = ui.make_persistent_id(output.response.id);
let copied_icon = ui.memory_mut(|m| *m.data.get_temp_mut_or_default::<bool>(persistent_id));

let copy_button = ui.put(
egui::Rect {
min: position,
max: position,
},
egui::Button::new(if copied_icon { "✔" } else { "🗐" })
.small()
.frame(false)
.fill(egui::Color32::TRANSPARENT),
);
let copy_button = ui
.put(
egui::Rect {
min: position,
max: position,
},
egui::Button::new(if copied_icon { "✔" } else { "🗐" })
.small()
.frame(false)
.fill(egui::Color32::TRANSPARENT),
)
// workaround for a regression after egui 0.27 where the edit cursor was shown even when
// hovering over the button. We try interact_cursor first to allow the cursor to be
// overriden
.on_hover_cursor(
ui.visuals()
.interact_cursor
.unwrap_or(egui::CursorIcon::Default),
);

// Update icon state in persistent memory
if copied_icon && !copy_button.hovered() {
Expand Down

0 comments on commit 930a5c5

Please sign in to comment.