1
0
Fork 0

Add keyboard modifiers to drag events

Remove fields from DragLeft
This commit is contained in:
Jussi Viiri 2023-06-05 21:00:19 +03:00
parent e9a1460a5b
commit fe03957514
2 changed files with 26 additions and 11 deletions

View file

@ -80,22 +80,28 @@ pub enum MouseEvent {
// TODO: Document // TODO: Document
DragEntered { DragEntered {
/// The logical coordinates of the mouse position
position: Point, position: Point,
/// The modifiers that were held down just before the event.
modifiers: Modifiers,
data: DropData, data: DropData,
}, },
DragMoved { DragMoved {
/// The logical coordinates of the mouse position
position: Point, position: Point,
/// The modifiers that were held down just before the event.
modifiers: Modifiers,
data: DropData, data: DropData,
}, },
DragLeft { DragLeft,
position: Point,
data: DropData,
},
DragDropped { DragDropped {
/// The logical coordinates of the mouse position
position: Point, position: Point,
/// The modifiers that were held down just before the event.
modifiers: Modifiers,
data: DropData, data: DropData,
}, },
} }

View file

@ -958,12 +958,17 @@ impl DropTarget {
) -> HRESULT ) -> HRESULT
{ {
let drop_target = &mut *(this as *mut DropTarget); let drop_target = &mut *(this as *mut DropTarget);
let window_state = unsafe { &*drop_target.window_state };
drop_target.parse_coordinates(pt); drop_target.parse_coordinates(pt);
drop_target.parse_drop_data(&*pDataObj); drop_target.parse_drop_data(&*pDataObj);
let event = MouseEvent::DragEntered { let event = MouseEvent::DragEntered {
position: drop_target.drag_position, position: drop_target.drag_position,
modifiers: window_state
.keyboard_state
.borrow()
.get_modifiers_from_mouse_wparam(grfKeyState as WPARAM),
data: drop_target.drop_data.clone(), data: drop_target.drop_data.clone(),
}; };
@ -979,11 +984,16 @@ impl DropTarget {
) -> HRESULT ) -> HRESULT
{ {
let drop_target = &mut *(this as *mut DropTarget); let drop_target = &mut *(this as *mut DropTarget);
let window_state = unsafe { &*drop_target.window_state };
drop_target.parse_coordinates(pt); drop_target.parse_coordinates(pt);
let event = MouseEvent::DragMoved { let event = MouseEvent::DragMoved {
position: drop_target.drag_position, position: drop_target.drag_position,
modifiers: window_state
.keyboard_state
.borrow()
.get_modifiers_from_mouse_wparam(grfKeyState as WPARAM),
data: drop_target.drop_data.clone(), data: drop_target.drop_data.clone(),
}; };
@ -993,13 +1003,7 @@ impl DropTarget {
unsafe extern "system" fn drag_leave(this: *mut IDropTarget) -> HRESULT { unsafe extern "system" fn drag_leave(this: *mut IDropTarget) -> HRESULT {
let drop_target = &mut *(this as *mut DropTarget); let drop_target = &mut *(this as *mut DropTarget);
drop_target.on_event(None, MouseEvent::DragLeft);
let event = MouseEvent::DragLeft {
position: drop_target.drag_position,
data: drop_target.drop_data.clone(),
};
drop_target.on_event(None, event);
S_OK S_OK
} }
@ -1012,12 +1016,17 @@ impl DropTarget {
) -> HRESULT ) -> HRESULT
{ {
let drop_target = &mut *(this as *mut DropTarget); let drop_target = &mut *(this as *mut DropTarget);
let window_state = unsafe { &*drop_target.window_state };
drop_target.parse_coordinates(pt); drop_target.parse_coordinates(pt);
drop_target.parse_drop_data(&*pDataObj); drop_target.parse_drop_data(&*pDataObj);
let event = MouseEvent::DragDropped { let event = MouseEvent::DragDropped {
position: drop_target.drag_position, position: drop_target.drag_position,
modifiers: window_state
.keyboard_state
.borrow()
.get_modifiers_from_mouse_wparam(grfKeyState as WPARAM),
data: drop_target.drop_data.clone(), data: drop_target.drop_data.clone(),
}; };