BlueGit

ict rusty-teams

Files

rusty-teams / crates / app-ui-kit / src / long_press.rs

long_press.rs

long_press.rs 1.4 KiB Download Raw
1use gpui_kit::*;
2
3pub fn long_press_right_click() -> impl IntoElement {
4 canvas(
5 |_, _, _| {},
6 |_, _, window, _| {
7 window.on_mouse_event(|event: &LongPressEvent, phase, window, cx| {
8 if phase != DispatchPhase::Bubble
9 || event.phase != TouchPhase::Started
10 || window.default_prevented()
11 {
12 return;
13 }
14 window.prevent_default();
15 let position = event.start_position;
16 window.defer(cx, move |window, cx| {
17 window.dispatch_event(
18 PlatformInput::MouseDown(MouseDownEvent {
19 button: MouseButton::Right,
20 position,
21 modifiers: Modifiers::default(),
22 click_count: 1,
23 first_mouse: false,
24 }),
25 cx,
26 );
27 window.dispatch_event(
28 PlatformInput::MouseUp(MouseUpEvent {
29 button: MouseButton::Right,
30 position,
31 modifiers: Modifiers::default(),
32 click_count: 1,
33 }),
34 cx,
35 );
36 });
37 });
38 },
39 )
40}