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

Hi,

please attach your code to the bug entry you are referring to. The best
way would be as patch to original source but you could also simply post
the code.

Tom

bbskill schrieb:
> Hi, I think I have found the bug. which is locate in the getItem method
> of the TableDragAndDropEffect class.
> below is the orignal code:
> Widget getItem(int x, int y) {
> Point coordinates = new Point(x, y);
> coordinates = table.toControl(coordinates);
> TableItem item = table.getItem(coordinates);
> if (item == null) {
> Rectangle area = table.getClientArea();
> if (area.contains(coordinates)) {
> // Scan across the width of the tree.
> for (int x1 = area.x; x1 < area.x + area.width; x1++) {
> Point pt = new Point(x1, coordinates.y);
> item = table.getItem(pt);
> if (item != null) {
> break;
> }
> }
> }
> }
> return item;
> }
> and it doesn't consider the height of the table's header if the header
> is set to be visible.I use the code below to obtain the
> DropTargetEvent's item according to its event.x and event.y,and it works
> fine.
> 
> Widget getItem(int x, int y) {
> Point coordinates = null;
> if(table.getHeaderVisible())
> coordinates = new Point(x, y event.y - table.getHeaderHeight());
> else coordinates = new Point(x, y event.y);
> coordinates = table.toControl(coordinates);
> TableItem item = table.getItem(coordinates);
> if (item == null) {
> Rectangle area = table.getClientArea();
> if (area.contains(coordinates)) {
> // Scan across the width of the tree.
> for (int x1 = area.x; x1 < area.x + area.width; x1++) {
> Point pt = new Point(x1, coordinates.y);
> item = table.getItem(pt);
> if (item != null) {
> break;
> }
> }
> }
> }
> return item;
> }
> 
>> 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 = "DD";
>> > }
>> > });
>> > // 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://bjcgi.163.net/cgi-bin/newreg.cgi? rf=050602>
> 
> <http://vip.tom.com/info/ggd_050409/index.html>    敲开精彩 聊天世界
> <http://chat.tom.com/>:网通用户 <http://chat.tom.com/> 电信用户
> <http://schat.tom.com/>
> 
> 明星金曲免费送(http://mm.tom.com/ivr/):周杰伦
> <http://fs.tom.com/ivr/search_ivrring.php?SingerName=周杰伦&user_id=
> 3&code_id=000000> 林俊杰
> <http://fs.tom.com/ivr/search_ivrring.php?SingerName=林俊杰&user_id=
> 3&code_id=000000> 庞龙
> <http://fs.tom.com/ivr/search_ivrring.php?SingerName=庞龙&user_id=
> 3&code_id=000000> 张惠妹
> <http://fs.tom.com/ivr/search_ivrring.php?SingerName=张惠妹&user_id=
> 3&code_id=000000>
> 
> 劲爆歌曲尽情点(http://mm.tom.com/ivr/):霍元甲
> <http://fs.tom.com/ivr/send_step1.php?Id=39244&user_id=3&code_id=w555>
> 吉祥三宝
> <http://fs.tom.com/ivr/send_step1.php?Id=38397&user_id=3&code_id=w555>
> 人质
> <http://fs.tom.com/ivr/send_step1.php?Id=39335&user_id=3&code_id=w555>
> 曹操 <http://fs.tom.com/ivr/send_step1.php?Id=39325&user_id=3&code_id=w555>
> 
> 炫酷彩铃免费送(http://mm.tom.com/cailing/):周杰伦帮你接电话
> <http://fs.tom.com/cailing/search.php?CurPage=1&user_id=3&Catalog=&phone_num=&SearchBy=ring&Keyword=%D6%DC%BD%DC%C2%D7%B0%EF%C4%E3%BD%D3%B5%E7%BB%B0>
> 麻烦女朋友
> <http://fs.tom.com/cailing/search.php?CurPage=1&user_id=3&Catalog=&phone_num=&SearchBy=ring&Keyword=%C2%E9%B7%B3%C5%AE%C5%F3%D3%D1>
> 七里香
> <http://fs.tom.com/cailing/search.php?CurPage=1&user_id=3&Catalog=&phone_num=&SearchBy=ring&Keyword=%C6%DF%C0%EF%CF%E3>
> 小城故事
> <http://fs.tom.com/cailing/search.php?CurPage=1&user_id=3&Catalog=&phone_num=&SearchBy=ring&Keyword=%D0%A1%B3%C7%B9%CA%CA%C2>
> 
> ===============================================
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> platform-swt-dev mailing list
> platform-swt-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/platform-swt-dev


-- 
B e s t S o l u t i o n . a t                        EDV Systemhaus GmbH
------------------------------------------------------------------------
tom schindl    leiter softwareentwicklung/CSE   mobile  ++43 676 3232147
------------------------------------------------------------------------
eduard-bodem-gasse 8/3    A-6020 innsbruck      fax      ++43 512 935833
http://www.bestsolution.at                      phone    ++43 512 935834

Attachment: signature.asc
Description: OpenPGP digital signature