简体   繁体   English

无鼠标拖放 - 更改事件的引发方式(以编程方式提升拖放/拖动事件)

[英]Mouseless Drag and Drop - change how the event are raised (raise drop/drag event programatically)

(first the question then I'll explain) (首先我要解释的问题)

How to tell the application to drop an object/raise the drop event programatically (I'm not using the mouse)? 如何告诉应用程序删除一个对象/以编程方式提升drop事件(我没有使用鼠标)?

I'm currently developing for the MSKinect, and I want to implement a Drag and Drop really close to the native drag and drop (see msdn doc ). 我目前正在为MSKinect开发,我想实现一个非常接近原生拖放的拖放(参见msdn doc )。

I've already implemented a drag and drop using a canvas and using the event raised by the Kinect cursors to "drag" things around. 我已经使用画布实现了拖放操作,并使用Kinect游标引发的事件来“拖动”周围的事物。 but I'm more interested in transferring data using the drag and drop. 但是我更感兴趣的是使用拖放来传输数据。

I know that usually the drop event is launched when the mouse button is released, I want to make the draggableElement release when a given gesture occurs. 我知道通常在释放鼠标按钮时启动drop事件,我想在给定手势发生时进行draggableElement释放。

Additional information: I'm implementing a Manager based on the LesterLobo's work 附加信息:我正在根据LesterLobo的工作实施经理

You can globally simulate mouse movements and clicks using the SendInput function of the Win32 API. 您可以使用Win32 API的SendInput函数全局模拟鼠标移动和单击。 You can find instructions on how to call the function using C# here . 您可以在此处找到有关如何使用C#调用该函数的说明。

The SendInput function is as close as it gets to actually using the mouse. SendInput函数与实际使用鼠标的距离非常近。 Unfortunately, it's not very convenient to work with. 不幸的是,使用起来不太方便。 You will have to simulate pressing the left mouse button, moving the mouse, and releasing the left mouse button. 您必须模拟按下鼠标左键,移动鼠标和释放鼠标左键。

Please note that this approach is intended for dragging stuff across applications, as well as within the application. 请注意,此方法旨在跨应用程序以及应用程序内拖动内容。 If you would just like to drag stuff around within the application, there is most likely a simpler solution. 如果您只想在应用程序中拖动内容,则很可能是一个更简单的解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM