Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: Re: [platform-swt-dev] About the event.item of DropTargetEvent!

ok,I have entered it.
And How do I do with this problem? the hardest problem is to judge whether the last item is droped.
Thanks!
> Please enter a bug report for the problem and attach the snippet. Thanks!
>
>
>
>
> bbskill <bbkills@xxxxxxx>
> Sent by: platform-swt-dev-bounces@xxxxxxxxxxx
> 05/19/2006 11:09 PM
> Please respond to
> "Eclipse Platform SWT component developers list."
>
>
> To
> platform-swt-dev@xxxxxxxxxxx
> cc
>
> Subject
> [platform-swt-dev] About the event.item of DropTargetEvent!
>
>
>
>
>
>
> Hi ,all,
> I have found s strage behavior of event.item of DragTargetEvent !.
> I set a DragSource and DragTarget to a
> Table whose headers are visible. And When I drag one of its item, the
> DrapTargetEvent.item doesn't point the
> right item, actually it seems it point down by one item. I think it
> counts for the visible headers of the table.
> below is my code:
> import org.eclipse.swt.*; import org.eclipse.swt.dnd.*;
> import org.eclipse.swt.layout.*;
> import org.eclipse.swt.widgets.*;
> /**
> * This program illustrates dragging
> */
> public class Snippet185 {
> /**
> * Runs the application
> */
> public void run() {
> Display display = new Display();
> Shell shell = new Shell(display);
> createContents(shell);
> shell.open();
> while (!shell.isDisposed()) {
> if (!display.readAndDispatch()) {
> display.sleep();
> }
> }
> display.dispose();
> }
> private void createContents(Shell shell) {
> shell.setLayout(new FillLayout());
>
> Table table = new Table(shell, SWT.BORDER | SWT.H_SCROLL |
> SWT.V_SCROLL);
> table.setHeaderVisible(true);
> TableColumn column = new TableColumn(table, SWT.NONE);
> column.setText("column 1");
> // Seed the table
> TableItem item = new TableItem(table, SWT.NONE);
> item.setText(new String[] { "Test 1"});
> item = new TableItem(table, SWT.NONE);
> item.setText(new String[] { "Test 2"});
> item = new TableItem(table, SWT.BORDER);
> item.setText(new String[] { "Test 3 "});
>
> // Seed the table
> column.pack();
> // Create the types
> Transfer[] types = new Transfer[] { TextTransfer.getInstance()};
> // Create the drag source
> DragSource source = new DragSource(table, DND.DROP_MOVE |
> DND.DROP_COPY);
> source.setTransfer(types);
> source.addDragListener(new DragSourceAdapter() {
> public void dragSetData(DragSourceEvent event) {
> event.data = "">> }
> });
> // Create the drop target
> DropTarget target = new DropTarget(table,
> DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_DEFAULT);
> target.setTransfer(types);
> target.addDropListener(new DropTargetAdapter() {
>
> public void drop(DropTargetEvent event) {
> System.out.println(event.item);
> }
> });
> }
> /**
> * The application entry point
> * @param args the command line arguments
> */
> public static void main(String[] args) {
> new Snippet185().run();
> }
> }
> _______________________________________________
> platform-swt-dev mailing list
> platform-swt-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/platform-swt-dev
>
>




===============================================
快来和我一起享受TOM免费邮箱吧! 看看除了1.5G,还有什么?

    敲开精彩 聊天世界网通用户 电信用户

明星金曲免费送(http://mm.tom.com/ivr/):周杰伦 林俊杰 庞龙 张惠妹

劲爆歌曲尽情点(http://mm.tom.com/ivr/):霍元甲 吉祥三宝 人质 曹操

炫酷彩铃免费送(http://mm.tom.com/cailing/):周杰伦帮你接电话 麻烦女朋友 七里香 小城故事
===============================================

Back to the top