Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » Support to click tree table cell, proposal(Code proposal to click tree cell)
Support to click tree table cell, proposal [message #493038] Thu, 22 October 2009 19:53 Go to next message
Jay Norwood is currently offline Jay NorwoodFriend
Messages: 155
Registered: July 2009
Senior Member
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 20:04 Go to previous messageGo to next message
Jay Norwood is currently offline Jay NorwoodFriend
Messages: 155
Registered: July 2009
Senior Member
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 20:26 Go to previous message
Jay Norwood is currently offline Jay NorwoodFriend
Messages: 155
Registered: July 2009
Senior Member
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?
Previous Topic:Virtual lists in Combo
Next Topic:How to Maximize/Restore/Minimize Views?
Goto Forum:
  


Current Time: Mon Sep 23 06:59:41 GMT 2024

Powered by FUDForum. Page generated in 0.03784 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top