Bug 259715 - API for sending traverse events to controls
Summary: API for sending traverse events to controls
Status: RESOLVED FIXED
Alias: None
Product: SWTBot
Classification: Technology
Component: SWTBot (show other bugs)
Version: 2.0.0-dev   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 2.0.0   Edit
Assignee: Ketan Padegaonkar CLA
QA Contact:
URL:
Whiteboard:
Keywords: noteworthy
Depends on:
Blocks:
 
Reported: 2008-12-28 00:07 EST by Ketan Padegaonkar CLA
Modified: 2009-01-04 05:23 EST (History)
1 user (show)

See Also:


Attachments
mylyn/context/zip (1.97 KB, application/octet-stream)
2008-12-28 01:12 EST, Ketan Padegaonkar CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ketan Padegaonkar CLA 2008-12-28 00:07:30 EST
Description copied from http://swtbot.org/bugzilla/show_bug.cgi?id=139:

It would be useful to be able to traverse controls using the keyboard with the bot API. A common use case is to enter text into a field and tab to set focus to the next field. (I need this for testing traversal ordering.)

To accommodate this, I played with an added a method like this:

public void typeKey(final char key) {
log.debug(MessageFormat.format(?Inserting text:{0} into text {1}?, key, this));

setFocus();
notifyKeyboardEvent(SWT.NONE, key);
}

and calling it like this:

text.typeKey(SWT.TAB);

Unfortunately, this doesn?t do the trick.

I also experimented with synthesizing a traverse event and sending it directly to the widget like this:

Event event = new Event();
event.type = SWT.Traverse;
event.time = (int) System.currentTimeMillis();
event.widget = projectName.widget;
text.notify(SWT.Traverse, event);

but no dice. (I didn?t entirely expect it to work but it was worth a try anyway.)

Any ideas?
Comment 1 Ketan Padegaonkar CLA 2008-12-28 01:11:24 EST
Fixed in trunk. Added some test cases SWTBot2#testTabKeyTraversalSetsFocusOnTheNextControlAndSendsTraverseEvents

Phil would you want to try this out with some testcases of your own ?

Comment 2 Ketan Padegaonkar CLA 2008-12-28 01:12:10 EST
Created attachment 121279 [details]
mylyn/context/zip