Support to click tree table cell, proposal [message #493038] |
Thu, 22 October 2009 15:53  |
Eclipse User |
|
|
|
I have a tree table that I'm testing, and needed a way to click in a specific cell in order to activate one of those controls that get created when you click the cell. I didn't see support for clicking a specific cell in SWTBotTreeItem, but there was code to click() on the first cell, which was almost correct.
So I would like to propse addition of this to SWTBotTreeItem:
/**
* Clicks on the cell at the specified column.
*
* @return the current node.
* @since 1.2
*/
public SWTBotTreeItem click(final int column) {
assertEnabled();
Rectangle cellBounds = syncExec(new Result<Rectangle>() {
public Rectangle run() {
return widget.getBounds(column);
}
});
clickXY(cellBounds.x + (cellBounds.width / 2), cellBounds.y + (cellBounds.height / 2));
return this;
}
So now I can click on a cell by index:
SWTBotTreeItem item = tree.expandNode("rowname").select().click(); // clicks cell 0 in that row
item.click(1); // to click in cell 1 in that row
|
|
|
Re: Support to click tree table cell, proposal [message #493041 is a reply to message #493038] |
Thu, 22 October 2009 16:04   |
Eclipse User |
|
|
|
I guess it would also be good to add a doubleClick(column). I haven't tested this (I did test the single click), but it looks like it might work based on what's done elsewhere with clickXY and doubleclick().
public SWTBotTreeItem doubleClick(final int column) {
assertEnabled();
Rectangle cellBounds = syncExec(new Result<Rectangle>() {
public Rectangle run() {
return widget.getBounds(column);
}
});
doubleClickXY(cellBounds.x + (cellBounds.width / 2), cellBounds.y + (cellBounds.height / 2));
return this;
}
protected void doubleClickXY(int x, int y) {
notifyTree(SWT.MouseEnter);
notifyTree(SWT.MouseMove);
notifyTree(SWT.Activate);
notifyTree(SWT.FocusIn);
notifyTree(SWT.MouseDown, createMouseEvent(x, y, 1, SWT.BUTTON1, 1));
notifyTree(SWT.MouseUp);
notifyTree(SWT.Selection, createEvent());
notifyTree(SWT.MouseDown);
notifyTree(SWT.MouseDoubleClick);
notifyTree(SWT.DefaultSelection,createEvent());
notifyTree(SWT.MouseUp);
notifyTree(SWT.MouseHover);
notifyTree(SWT.MouseMove);
notifyTree(SWT.MouseExit);
notifyTree(SWT.Deactivate);
notifyTree(SWT.FocusOut);
}
|
|
|
Re: Support to click tree table cell, proposal [message #493048 is a reply to message #493041] |
Thu, 22 October 2009 16:26  |
Eclipse User |
|
|
|
After the button had been successfully created in the cell, in response to the click, I still had to find a way to launch that particular button. While we have a lot of useful matchers ... inGroup, withId, withLabel, and so on... we don't currently have a way to limit the search range to a cell boundary. It would be very useful to have something to do that.
Something like:
buttonInTreeCell(TreeItem row, int column );
buttonInTreeCell(int row,int column);
or maybe something using the cell boundaries:
Rectangle rect = treeItem.cellRect(int column);
SWTBotButton button = buttonInRect(rect);
Would an InRect matcher, in general, be useful for locating widgets in table cells?
|
|
|
Powered by
FUDForum. Page generated in 0.12536 seconds