File tree 2 files changed +9
-2
lines changed
2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -27,14 +27,15 @@ impl DragAndDrop {
27
27
}
28
28
29
29
fn end_frame ( ctx : & Context ) {
30
- let pointer_released = ctx. input ( |i| i. pointer . any_released ( ) ) ;
30
+ let abort_dnd =
31
+ ctx. input ( |i| i. pointer . any_released ( ) || i. key_pressed ( crate :: Key :: Escape ) ) ;
31
32
32
33
let mut is_dragging = false ;
33
34
34
35
ctx. data_mut ( |data| {
35
36
let state = data. get_temp_mut_or_default :: < Self > ( Id :: NULL ) ;
36
37
37
- if pointer_released {
38
+ if abort_dnd {
38
39
state. payload = None ;
39
40
}
40
41
Original file line number Diff line number Diff line change @@ -134,6 +134,12 @@ pub(crate) fn interact(
134
134
let mut dragged = prev_snapshot. dragged ;
135
135
let mut long_touched = None ;
136
136
137
+ if input. key_pressed ( Key :: Escape ) {
138
+ // Abort dragging on escape
139
+ dragged = None ;
140
+ interaction. potential_drag_id = None ;
141
+ }
142
+
137
143
if input. is_long_touch ( ) {
138
144
// We implement "press-and-hold for context menu" on touch screens here
139
145
if let Some ( widget) = interaction
You can’t perform that action at this time.
0 commit comments