Focus, what does it mean?

http://ai2.appinventor.mit.edu.ezproxy.canberra.edu.au/reference/components/userinterface.html

A

GotFocus(), LostFocus(), these two components, who can give an example?

GotFocus() for a textbox is something like which activates the tb and we can type in it. Generally a colored border is added around it. When this happens, the GotFocus event is called.

The opposite to this is the LostFocus(). Say you have a textbox for username and a password (1+ textboxes on a screen) and the app would like to be informed when the user has shifted from a textbox to some other, then the LostFocus event is called.

Also look here

1 Like

In my opinion, GotFocus() works like for example you have 3 textboxes and when you press the first textbox you can bring up a notification before you type something in the textbox,

or you can also use this block to set the textbox that you want to focus on :
blocks

and LostFocus() works for example you want to leave the first textbox by pressing the second textbox, you can bring up a notification.

3 Likes

an example
blocks(11)

You asked about Button Focus.

@ewpatton provided this answer a while ago on the forum(paraphrased):

The original use of the GotFocus/LostFocus events were when Android phones had trackballs to navigate the UI. Focus would move when you moved the trackball highlight over a component (e.g., button). In the days of touch screens and no trackballs, the events still exist but are likely only triggered in limited circumstances (using tab key in an emulator being one, accessibility focus is another).

1 Like

Does Focus only apply to TextBox components?

Other components, for example: Button.... Can it not be used?

you can use all of them, but for button I find it difficult to explain it to you, I think you have to do a project to research it, so you can know how it works.

1 Like