setFocus vs. forceFocus

WindowTester allows you to easily create and run unit tests for every GUI they build. It can also be used to generate system level tests.

Moderators: gnebling, Eric Clayberg, Dan Rubel, keertip, Phil Quitslund

setFocus vs. forceFocus

Postby ecpasour » Thu Apr 05, 2007 4:56 am

Hi. I just started using WindowTester and I ran into an issue with clicking on items that don't take normal focus.

In my widget, I have a Composite that needs to get focus. The composite contains some labels but no traditionally focusable widgets. I can tab to the composite, but calling composite.setFocus() gets ignored. I found that calling composite.forceFocus() yielded the desired behavior.

So in trying to test my widget with WindowTester, I found that calling ui.click(<widget locator>); appears to have the same issue. At least the focus is not where I expect after execution.

Am I missing something? I am working around the issue, but it will probably crop up again.
ecpasour
 
Posts: 2
Joined: Wed Apr 04, 2007 6:38 am

Postby Phil Quitslund » Mon Apr 09, 2007 9:34 am

Interesting issue! Let me see if I have this right: you say that using the WindowTester runtime, you click a widget after which you would expect the item to have focus but it does not? Where is the focus? And are you saying that this sequence gives you the desired results?

Code: Select all
ui.click([locator]);
composite.forceFocus();


And after this, what has focus? The composite? Or a widget in the composite?

Lastly, is this your own custom composite? Can you share a code snippet that will help us reproduce this behavior?
--
Phil Quitslund
Software Engineer
Google, Inc.
Phil Quitslund
Moderator
 
Posts: 491
Joined: Fri Apr 28, 2006 6:26 am

Postby ecpasour » Thu Apr 12, 2007 10:27 am

Okay, it looks like I've figured out what I was doing wrong. I was calling ui.click() on the Composite. But in my code I was actually handling mouse click on the labels inside the composite and then calling forceFocus() on the composite. Changing my test to more closely mimic the actual code seems to work.

Sorry about the false alarm.
ecpasour
 
Posts: 2
Joined: Wed Apr 04, 2007 6:38 am

Postby Phil Quitslund » Fri Apr 13, 2007 8:33 am

Cool, glad you're unblocked.

Thanks for the follow-up!
--
Phil Quitslund
Software Engineer
Google, Inc.
Phil Quitslund
Moderator
 
Posts: 491
Joined: Fri Apr 28, 2006 6:26 am


Return to Window Tester

Who is online

Users browsing this forum: No registered users and 1 guest