Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions .Jules/palette.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 2024-05-23 - Makepad Tooltips Implementation
**Learning:** Tooltips in Makepad are not automatic properties of widgets. They must be implemented by handling `Hit::FingerHoverIn` and `Hit::FingerHoverOut` events in the widget's `handle_event` method and dispatching `TooltipAction::HoverIn` and `TooltipAction::HoverOut`.
**Action:** When adding tooltips to custom widgets, ensure the widget implements `handle_event` to intercept hover events and dispatch the appropriate actions to the global tooltip handler.
29 changes: 29 additions & 0 deletions src/shared/jump_to_bottom_button.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use makepad_widgets::*;
use crate::shared::callout_tooltip::{CalloutTooltipOptions, TooltipAction, TooltipPosition};

const SCROLL_TO_BOTTOM_SPEED: f64 = 90.0;

Expand Down Expand Up @@ -99,6 +100,34 @@ pub struct JumpToBottomButton {

impl Widget for JumpToBottomButton {
fn handle_event(&mut self, cx: &mut Cx, event: &Event, scope: &mut Scope) {
let uid = self.widget_uid();
let button = self.button(ids!(jump_to_bottom_button));

match event.hits(cx, button.area()) {
Hit::FingerHoverIn(_) => {
cx.widget_action(
uid,
&scope.path,
TooltipAction::HoverIn {
text: "Jump to bottom".to_string(),
widget_rect: button.area().rect(cx),
options: CalloutTooltipOptions {
position: TooltipPosition::Left,
..Default::default()
},
},
);
}
Hit::FingerHoverOut(_) => {
cx.widget_action(
uid,
&scope.path,
TooltipAction::HoverOut,
);
}
_ => {}
}

self.view.handle_event(cx, event, scope);
}

Expand Down