mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-25 14:51:30 +11:00
Added event for cancelling a drag and drop.
This commit is contained in:
parent
5f00028f6b
commit
06e01e4cb3
|
@ -26,11 +26,14 @@ pub enum WindowEvent {
|
||||||
/// The window has been closed.
|
/// The window has been closed.
|
||||||
Closed,
|
Closed,
|
||||||
|
|
||||||
|
/// A file has been dropped into the window.
|
||||||
|
DroppedFile(PathBuf),
|
||||||
|
|
||||||
/// A file is being hovered over the window.
|
/// A file is being hovered over the window.
|
||||||
HoveredFile(PathBuf),
|
HoveredFile(PathBuf),
|
||||||
|
|
||||||
/// A file has been dropped into the window.
|
/// A file was hovered, but has exited the window.
|
||||||
DroppedFile(PathBuf),
|
HoveredFileCancelled,
|
||||||
|
|
||||||
/// The window received a unicode character.
|
/// The window received a unicode character.
|
||||||
ReceivedCharacter(char),
|
ReceivedCharacter(char),
|
||||||
|
|
|
@ -143,9 +143,7 @@ impl WindowDelegate {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Invoked when the image is released
|
/// Invoked when the image is released
|
||||||
extern fn prepare_for_drag_operation(_: &Object, _: Sel, _: id) {
|
extern fn prepare_for_drag_operation(_: &Object, _: Sel, _: id) {}
|
||||||
println!("prepare_for_drag_operation");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Invoked after the released image has been removed from the screen
|
/// Invoked after the released image has been removed from the screen
|
||||||
extern fn perform_drag_operation(this: &Object, _: Sel, sender: id) -> BOOL {
|
extern fn perform_drag_operation(this: &Object, _: Sel, sender: id) -> BOOL {
|
||||||
|
@ -174,13 +172,15 @@ impl WindowDelegate {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Invoked when the dragging operation is complete
|
/// Invoked when the dragging operation is complete
|
||||||
extern fn conclude_drag_operation(_: &Object, _: Sel, _: id) {
|
extern fn conclude_drag_operation(_: &Object, _: Sel, _: id) {}
|
||||||
println!("conclude_drag_operation");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Invoked when the dragging operation is cancelled
|
/// Invoked when the dragging operation is cancelled
|
||||||
extern fn dragging_exited(_: &Object, _: Sel, _: id) {
|
extern fn dragging_exited(this: &Object, _: Sel, _: id) {
|
||||||
println!("dragging_exited");
|
unsafe {
|
||||||
|
let state: *mut c_void = *this.get_ivar("winitState");
|
||||||
|
let state = &mut *(state as *mut DelegateState);
|
||||||
|
emit_event(state, WindowEvent::HoveredFileCancelled);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static mut DELEGATE_CLASS: *const Class = 0 as *const Class;
|
static mut DELEGATE_CLASS: *const Class = 0 as *const Class;
|
||||||
|
@ -204,7 +204,7 @@ impl WindowDelegate {
|
||||||
decl.add_method(sel!(windowDidResignKey:),
|
decl.add_method(sel!(windowDidResignKey:),
|
||||||
window_did_resign_key as extern fn(&Object, Sel, id));
|
window_did_resign_key as extern fn(&Object, Sel, id));
|
||||||
|
|
||||||
// callback for drag events
|
// callbacks for drag and drop events
|
||||||
decl.add_method(sel!(draggingEntered:),
|
decl.add_method(sel!(draggingEntered:),
|
||||||
dragging_entered as extern fn(&Object, Sel, id) -> BOOL);
|
dragging_entered as extern fn(&Object, Sel, id) -> BOOL);
|
||||||
decl.add_method(sel!(prepareForDragOperation:),
|
decl.add_method(sel!(prepareForDragOperation:),
|
||||||
|
|
Loading…
Reference in a new issue