Consultor Eletrônico



Kbase 17858: How to set focus to a particular control in Apptivity
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   5/13/1998
How to set focus to a particular control in Apptivity

This knowledgebase entry describes how to set focus to a particular
control on a form in an Apptivity application.

Use abApplication.setFocusTo(View focusTo)

To set focus to a control, use the method
abApplication.setFocusTo(View focusTo). For example, to set
focus to the textField1 control, code the following:

abApplication.setFocusTo((View) textField1);

Why not use awt.component.requestFocus?

Apptivity engineering discovered that the AWT method requestFocus
does not always perform as desired, especially if the method is
called from within an event handler, for instance gotFocus or
lostFocus. To insure that Apptivity developers can reliably
set focus to a particular control in Apptivity applications,
Apptivity supplies the method abApplication.setFocusTo.

How does abApplication.setFocusTo work?

abApplication.setFocusTo puts in the event queue a request to move
focus to the specified view. The event is processed after other
already-queued events have been processed. This differs from a call
to requestFocus which tries to move focus to the view immediately,
outside of the event queue.

Can I still use awt.component.requestFocus?

You can still call awt.component.requestFocus directly if you wish,
however there may be cases where focus does not change as you
expect. In addition, abApplication.setFocusTo is more portable.
If there are changes to AWT or underlying APIs you will not need
to change your code. Those changes will be handled for you in the
implementation of abApplication.setFocusTo.

UTF
4/20/98
Apptivity 2.0

Progress Software Technical Support Note # 17858