Missing GetFocus() method

Bug reports.
Gryphyn
Posts: 15
Joined: Wed Dec 06, 2006 11:59 pm

Missing GetFocus() method

Post by Gryphyn » Tue Jun 26, 2007 11:53 pm

xPost

Ranorex 1.2
.Net 2.0

I've just upgraded to Ranorex 1.2
When I go to recompile I get an error for every instance of
"Control <control> = <Form>.GetFocus()"

Investigation shows that this method is missing from the latest release.
:cry:

Cheers
Gryphyn

webops
Site Admin
Site Admin
Posts: 349
Joined: Wed Jul 05, 2006 7:44 pm

Post by webops » Wed Jun 27, 2007 9:51 pm

Investigation shows that this method is missing from the latest release.
I tried the following code with the VS2005Application.exe and it worked for me:

Code: Select all

for (int i = 0; i < 60; i++)
{
    Control control = Form.GetFocus();
    Console.WriteLine("Control = {0}", control.GetType());
    Application.Sleep(1000);
}
GetFocus is a static method, please use Form.GetFocus() and not an instance object.

Jenö
Ranorex Team

Gryphyn
Posts: 15
Joined: Wed Dec 06, 2006 11:59 pm

Post by Gryphyn » Thu Jun 28, 2007 12:37 am

OK.
The method is not missing, it's changed to a static method.
--Intellisense couldn't/can't find it.

but this is still a change from previous versions where GetFocus() was a valid method for any Form object.

This now means that my code needs to bring the appropriate FORM into focus, before checking which CONTROL is in focus. (I'm assuming the static method is using the focused FORM)

-- off to branch my code stream --
(old code needs to compile against earlier Ranorex versions.)

A simple upgrade got awfully messy...

Cheers
Gryphyn

webops
Site Admin
Site Admin
Posts: 349
Joined: Wed Jul 05, 2006 7:44 pm

Post by webops » Thu Jun 28, 2007 10:12 pm

This now means that my code needs to bring the appropriate FORM into focus, before checking which CONTROL is in focus. (I'm assuming the static method is using the focused FORM)
GetFocus attaches to the currently activ form and returns the control that has the keyboard focus.
I checked the version history in Subversion. The function seems to be the same except that the function is static.

Sorry for the inconvenience.

Jenö
Ranorex Team