简体   繁体   English

SWT:拖放内部对象

[英]SWT: Drag-and-drop Internal Object

My application has a canvas and a table, I need to add drag-and-drop capabilities to it. 我的应用程序有一个画布和一个表,我需要添加拖放功能。 However, I read in a tutorial that Transfer converts the data I want to move into a platform-independent type. 但是,我在教程中读到,Transfer将我想要移动的数据转换为与平台无关的类型。 I have no need to drag anything outside of my program, and it's important that the exact object be sent. 我没有必要在我的程序之外拖动任何东西,并且确切的对象被发送是很重要的。 How can this be done? 如何才能做到这一点?

Okay, I figured it out. 好的,我明白了。 Apparently you can use some bogus transfer object, and keep the objects you want to move in your own variable. 显然,您可以使用一些伪造的转移对象,并保留您想要在自己的变量中移动的对象。 Define the variable when the drag starts, (from the DragSource ), and get the item from the variable in DropTarget . 拖动开始时定义变量(来自DragSource ),并从DropTarget的变量中获取项目。 Just ignore the bogus transfer object. 只需忽略伪造的转移对象。

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

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