private File getTargetFile(DropTargetEvent event) { // Determine the target File for the drop TreeItem item = tree.getItem(tree.toControl(new Point(event.x, event.y))); File targetFile = null; if (item != null) { // We are over a particular item in the tree, use the item's file targetFile = (File) item.getData(TREEITEMDATA_FILE); } return targetFile; } });
@Override protected void specialPopupMenuItems(Menu menu, Event event) { MenuItem item = new MenuItem(menu, SWT.PUSH); item.setText("getItem(Point) on mouse coordinates"); final Tree t = (Tree) event.widget; menuMouseCoords = t.toControl(new Point(event.x, event.y)); item.addSelectionListener(widgetSelectedAdapter(e -> { eventConsole.append ("getItem(Point(" + menuMouseCoords + ")) returned: " + t.getItem(menuMouseCoords)); eventConsole.append ("\n"); })); } }
Widget getItem(Tree tree, int x, int y) { Point point = new Point(x, y); point = tree.toControl(point); TreeItem item = tree.getItem(point); if (item == null) { Rectangle area = tree.getClientArea(); if (area.contains(point)) { int treeBottom = area.y + area.height; item = tree.getTopItem(); while (item != null) { Rectangle rect = item.getBounds(); int itemBottom = rect.y + rect.height; if (rect.y <= point.y && point.y < itemBottom) return item; if (itemBottom > treeBottom) break; item = nextItem(tree, item); } return null; } } return item; }
Widget getItem(Tree tree, int x, int y) { Point point = new Point(x, y); point = tree.toControl(point); TreeItem item = tree.getItem(point); if (item == null) { Rectangle area = tree.getClientArea(); if (area.contains(point)) { int treeBottom = area.y + area.height; item = tree.getTopItem(); while (item != null) { Rectangle rect = item.getBounds(); int itemBottom = rect.y + rect.height; if (rect.y <= point.y && point.y < itemBottom) return item; if (itemBottom > treeBottom) break; item = nextItem(tree, item); } return null; } } return item; }
Widget getItem(Tree tree, int x, int y) { Point point = new Point(x, y); point = tree.toControl(point); TreeItem item = tree.getItem(point); if (item == null) { Rectangle area = tree.getClientArea(); if (area.contains(point)) { int treeBottom = area.y + area.height; item = tree.getTopItem(); while (item != null) { Rectangle rect = item.getBounds(); int itemBottom = rect.y + rect.height; if (rect.y <= point.y && point.y < itemBottom) return item; if (itemBottom > treeBottom) break; item = nextItem(tree, item); } return null; } } return item; }
Widget getItem(Tree tree, int x, int y) { Point point = new Point(x, y); point = tree.toControl(point); TreeItem item = tree.getItem(point); if (item == null) { Rectangle area = tree.getClientArea(); if (area.contains(point)) { int treeBottom = area.y + area.height; item = tree.getTopItem(); while (item != null) { Rectangle rect = item.getBounds(); int itemBottom = rect.y + rect.height; if (rect.y <= point.y && point.y < itemBottom) return item; if (itemBottom > treeBottom) break; item = nextItem(tree, item); } return null; } } return item; }
Widget getItem(Tree tree, int x, int y) { Point point = new Point(x, y); point = tree.toControl(point); TreeItem item = tree.getItem(point); if (item == null) { Rectangle area = tree.getClientArea(); if (area.contains(point)) { int treeBottom = area.y + area.height; item = tree.getTopItem(); while (item != null) { Rectangle rect = item.getBounds(); int itemBottom = rect.y + rect.height; if (rect.y <= point.y && point.y < itemBottom) return item; if (itemBottom > treeBottom) break; item = nextItem(tree, item); } return null; } } return item; }
Widget getItem(Tree tree, int x, int y) { Point point = new Point(x, y); point = tree.toControl(point); TreeItem item = tree.getItem(point); if (item == null) { Rectangle area = tree.getClientArea(); if (area.contains(point)) { int treeBottom = area.y + area.height; item = tree.getTopItem(); while (item != null) { Rectangle rect = item.getBounds(); int itemBottom = rect.y + rect.height; if (rect.y <= point.y && point.y < itemBottom) return item; if (itemBottom > treeBottom) break; item = nextItem(tree, item); } return null; } } return item; }
@Override public void menuShown(MenuEvent e) { Utils.disposeSWTObjects(menuTree.getItems()); bShown = true; Point ptMouse = tree.toControl(e.display.getCursorLocation()); int indent = END_INDENT ? tree.getClientArea().width - 1 : 0; TreeItem treeItem = tree.getItem(new Point(indent, ptMouse.y)); if (treeItem == null) { return; } SideBarEntrySWT entry = (SideBarEntrySWT) treeItem.getData("MdiEntry"); fillMenu(menuTree, entry, "sidebar"); if (menuTree.getItemCount() == 0) { Utils.execSWTThreadLater(0, new AERunnable() { @Override public void runSupport() { menuTree.setVisible(false); } }); } } });
clientArea), tree.toControl(cursorLocation)); if (result != null) { result.x = result.x + getAvarageCharWith(tree) * CHAR_INDENT;
tree.toControl(cursorLocation)); if (result != null) result.x= result.x + getAvarageCharWith(tree) * CHAR_INDENT;
coordinates = DPIUtil.autoScaleUp(tree.toControl(coordinates)); long /*int*/ [] path = new long /*int*/ [1]; OS.gtk_tree_view_get_path_at_pos (handle, coordinates.x, coordinates.y, path, null, null, null);
coordinates = DPIUtil.autoScaleUp(tree.toControl(coordinates)); int /*long*/ [] path = new int /*long*/ [1]; OS.gtk_tree_view_get_path_at_pos (handle, coordinates.x, coordinates.y, path, null, null, null);
coordinates = DPIUtil.autoScaleUp(tree.toControl(coordinates)); int /*long*/ [] path = new int /*long*/ [1]; OS.gtk_tree_view_get_path_at_pos (handle, coordinates.x, coordinates.y, path, null, null, null);
int /*long*/ handle = tree.handle; Point coordinates = new Point(event.x, event.y); coordinates = DPIUtil.autoScaleUp(tree.toControl(coordinates)); // To Pixels TVHITTESTINFO lpht = new TVHITTESTINFO (); lpht.x = coordinates.x;
Point point = tree.toControl(new Point(event.x, event.y)); Rectangle bounds = tree.getClientArea();
Point cursorLocation = tree.toControl(event.display.getCursorLocation()); if (lastCloseAreaClicked != null && lastCloseAreaClicked.contains(cursorLocation.x, cursorLocation.y)) { return;