Skip to content

Commit

Permalink
add some cursor style
Browse files Browse the repository at this point in the history
  • Loading branch information
dzhou121 committed Sep 3, 2023
1 parent 614a8a3 commit 1f1c700
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ pub enum CursorStyle {
Default,
Pointer,
Text,
ColResize,
RowResize,
}

#[derive(Debug, Clone, Copy)]
Expand Down
10 changes: 10 additions & 0 deletions src/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,11 @@ pub trait View {
}
}
}
if let Some(action) = cx.get_event_listener(id, &EventListener::PointerMove) {
if (*action)(&event) {
return true;
}
}
}
Event::PointerUp(pointer_event) => {
if pointer_event.button.is_primary() {
Expand Down Expand Up @@ -577,6 +582,11 @@ pub trait View {
}
}
}
if let Some(action) = cx.get_event_listener(id, &EventListener::PointerUp) {
if (*action)(&event) {
return true;
}
}
} else if pointer_event.button.is_secondary() {
let rect = cx.get_size(self.id()).unwrap_or_default().to_rect();
let on_view = rect.contains(pointer_event.pos);
Expand Down
2 changes: 2 additions & 0 deletions src/window_handle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,8 @@ impl WindowHandle {
Some(CursorStyle::Default) => CursorIcon::Default,
Some(CursorStyle::Pointer) => CursorIcon::Pointer,
Some(CursorStyle::Text) => CursorIcon::Text,
Some(CursorStyle::ColResize) => CursorIcon::ColResize,
Some(CursorStyle::RowResize) => CursorIcon::RowResize,
None => CursorIcon::Default,
};
if cursor != self.app_state.last_cursor {
Expand Down

0 comments on commit 1f1c700

Please sign in to comment.