PDA

View Full Version : Screen.SetFocus()


csd214
09-27-2004, 04:15 PM
When a Verify Serial Number (or an Edit Field) screen appears, I want the first input box to have the focus. I entered the Screen.SetFocus() command as a On Preload action. It did not work. I added Screen.GetFocus(), and 821 (=CTRL_EDIT_01) was reported before the screen showed up, but always the Next button had the focus (I had to press TAB twice to enter the input box).

The help file is cryptic:
Note: This action will not function correctly if called from the On Preload event. You cannot set focus to static controls or controls that are not visible, or disabled.

At last I found a working solution:

On Preload:
Screen.StartTimer(500);

On Ctrl Message:
if MSGID_ONTIMER then
Screen.SetFocus(CTRL_EDIT_01);
end

If this is "the way to do it", it should be added to the help doc.

In any case: This solution works excellent.

Darryl
09-29-2004, 09:30 AM
I agree that this isn't the best way to do it, however from what I can see, it seems to be the "only" way to do it. I'll submit a report to see if something can be done in this respect, however I believe there may be undesirable results if it was changed.

Darryl

csd214
10-04-2004, 02:19 AM
I suggest to add a line to stop the timer:

if MSGID_ONTIMER then
Screen.SetFocus(CTRL_EDIT_01);
Screen.StopTimer();
--Note: The screen's timer is automatically stopped when a different screen is displayed.
end

csd214
04-18-2005, 05:05 PM
Forget this old stuff!

With v7.0.2.0 you only need Screen.SetFocus(CTRL_EDIT_01) in the On Preload pane.

(Ref. http://www.indigorose.com/forums/showthread.php?t=11112)