From 2fb2cd59a9c37ea5307339fa1a00a9ee7636f495 Mon Sep 17 00:00:00 2001 From: Isaac Mills Date: Tue, 19 Mar 2024 18:22:48 -0400 Subject: [PATCH] Pointer hand on hover --- src/app.rs | 45 ++++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/src/app.rs b/src/app.rs index 71a3126..cd9de44 100644 --- a/src/app.rs +++ b/src/app.rs @@ -638,27 +638,31 @@ impl eframe::App for Portfolio { let mut buffer = buffer.write(); let mut editor = Editor::new(BufferRef::Borrowed(buffer.deref_mut())); - // if text_response.hovered() - // && ui.input(|i| i.raw_scroll_delta == Vec2::ZERO) - // { - // let mouse_pos = ui - // .input(|i| i.pointer.latest_pos().unwrap_or_default()) - // - text_rect.min.to_vec2(); + if text_response.hovered() + && ui.input(|i| i.raw_scroll_delta == Vec2::ZERO) + { + let mouse_pos = ui + .input(|i| i.pointer.latest_pos().unwrap_or_default()) + - text_rect.min.to_vec2(); - // editor.action( - // self.font_system.lock().deref_mut(), - // glyphon::Action::Click { - // x: mouse_pos.x as i32, - // y: mouse_pos.y as i32 - 3, - // }, - // ); + editor.action( + self.font_system.lock().deref_mut(), + glyphon::Action::Click { + x: mouse_pos.x as i32, + y: mouse_pos.y as i32 - 3, + }, + ); - // let mut location = editor.cursor(); - // match location.affinity { - // glyphon::Affinity::After => location.index += 1, - // glyphon::Affinity::Before => {} - // } - // } + let mut location = editor.cursor(); + match location.affinity { + glyphon::Affinity::After => location.index += 1, + glyphon::Affinity::Before => {} + } + + if url_map.get(location.index).is_some() { + ctx.set_cursor_icon(egui::CursorIcon::PointingHand); + } + } if text_response.clicked() && !self.image_zoomed { let mouse_click = ui.input(|i| { i.pointer.interact_pos().unwrap_or_default() @@ -927,6 +931,9 @@ impl eframe::App for Portfolio { scroll_area.state.store(ui.ctx(), scroll_area.id); } self.hover(hovered, ui); + if self.hovered { + ctx.set_cursor_icon(egui::CursorIcon::PointingHand); + } ui.painter().add(egui_wgpu::Callback::new_paint_callback( ui.max_rect(), GlyphonRendererCallback { buffers },