Reputation: 11
How to cause the click/ selection event in SWT through code ? without the user actually clicking the control, the event should be fired !! is it possible?
I need to automate the clicking of a combo box button and the dropping down of the list and the selection of the item - as done by the user!! i.e., playback of the recorded events. Which listener do i need to use ? i tried selection but couldn't get the results.
combo.setText(combo.getItem(combo.getSelectionIndex()));
Upvotes: 0
Views: 1580
Reputation: 176
If you want to simulate the user interactions for testing purpose, try windowstester. It also has recording feature where you can record the ui activities and just run it over the test...
https://developers.google.com/java-dev-tools/download-wintester
Upvotes: 0
Reputation: 111142
You can simulate a selection event with something like:
Event event = new Event();
event.widget = combo;
event.type = SWT.Selection;
combo.getDisplay().post(event);
You might need to set other fields in Event
Upvotes: 1