1

在我谷歌之前:

http://www.zkoss.org/zkdemo/event/client-side_event_handling

但我不明白。

请告诉我:

在 zk 中使用 onFocus 和 onBlur 属性的目的是什么?

4

1 回答 1

3

In this context, "focus" refers to a form field being the field currently accepting user input.

1) A field can have focus by default on initial render:

<textbox focus="true"/>

2) A field can be given focus by ZK:

public void focusOnTextbox() {
    myTextbox.setFocus(true);
}

3) A field can gain focus when the user clicks on it, as shown in the demo you referenced.

Inherent to the concept of focus, only one field can have focus at a time. Thus, when a second field gains focus, the first field loses focus; this is known as "blurring".

1) A field can blur when another field gains focus.

2) A field can blur when the user clicks outside the field, at this point no fields have focus.

3) A field can blur when it's focus is removed by ZK:

public void focusOffTextbox() {
    myTextbox.setFocus(false);
}
于 2013-11-18T18:19:49.517 回答