public class Event extends Object
On the other hand, a DOM event (Event
) is the low-level event
related to DOM elements. It is usually listened by the implementation of a widget, rather than the client application.
In additions, zWatch
is an utility to manage the system-level events,
and both the client application and the widget implementation might listen.
To fire a widget event, use Widget.fire(_global_.String, zk.Object, _global_.Map, int)
.
To listen a widget event, use Widget.listen(_global_.Map, int)
.
See Also
Common Key Codes:
BACKSSPACE | 8 | TAB | 9 | ENTER | 13 | SHIFT | 16 | CTRL | 17 |
ALT | 18 | ESC | 27 | PGUP | 33 | PGDN | 34 | END | 35 |
HOME | 36 | LEFT | 37 | UP | 38 | RIGHT | 39 | DOWN | 40 |
INS | 45 | DEL | 46 | F1 | 112 |
Modifier and Type | Field and Description |
---|---|
boolean |
auStopped
Indicates whether to stop the sending of the AU request to the server.
|
Widget |
currentTarget
Indicates the target which is handling this event.
|
Object |
data
The data which depends on the event.
|
Event |
domEvent
The DOM event that causes this widget event, or null if not available.
|
boolean |
domStopped
Indicates whether to stop the native DOM event.
|
DOMElement |
domTarget
The DOM element that the event is targeting, or null if not available.
|
String |
name
The event name, such as 'onChange'.
|
Map |
opts
The options (never null).
|
boolean |
stopped
Indicates whether the event propagation is stopped.
|
Widget |
target
The target widget (readonly).
|
Modifier and Type | Method and Description |
---|---|
void |
$init(Widget target,
String name,
Object data,
Map opts,
Event domEvent)
Constructor.
|
void |
addOptions(Map opts)
Adds the additions options to
opts . |
boolean |
isPressed(String... The)
Indicates whether a key is currently pressed.
|
void |
stop(Map opts)
Stop the event propagation.
|
$init, $instanceof, $super, $super, $supers, $supers, afterInit, isAssignableFrom, isInstance, proxy
public Widget target
currentTarget
public Widget currentTarget
By default, an event will be propagated to its parent, and this member tells which widget is handling it, while #target is the widget that the event is targeting.
target
public String name
However, if data is an instance of Map, its content is copied to the event instance. Thus, you can access them directly with the event instance as follows.
onClick: function (evt) {
if (evt.altKey) { //it is the same as evt.data.altKey
}
}
public Object data
Data can be any javascript Object. You can bring Number, String or JSON object to server side with it.
The javascript JSON object will be transfered to org.zkoss.json.JSONObject at server side as the following:
// at client side
var json = { "aa" : [{"a11":"11", "a12":12},{"a21":"21","a22":22.2}],
"bb":[{"b11":"31","b12":"32"},{"b21":"41","b22":"42","b23":43}]
},
data = {jsonObject:json};
// at server side
final JSONObject jsonObject = (JSONObject)data.get("jsonObject"); // get JSONObject
// will output "22.2"
System.out.println(((JSONObject)((JSONArray)jsonObject.get("aa")).get(1)).get("a22"));
// will output "class java.lang.Double"
System.out.println(((JSONObject)((JSONArray)jsonObject.get("aa")).get(1)).get("a22").getClass());
However, if data is an instance of Map, its content is copied to the event instance. Thus, you can access them directly with the event instance as follows.
onClick: function (evt) {
if (evt.altKey) { //it is the same as evt.data.altKey
}
}
Refer to ZK Client-side Reference: AU Requests: Server-side Processing.
public Map opts
Allowed properties:
Map
) that can be anything and will be passed to
the onResponse
watch (see also zWatch
).public Event domEvent
public DOMElement domTarget
public boolean stopped
stop(_global_.Map)
,
auStopped
,
domStopped
public boolean auStopped
stop(_global_.Map)
,
stopped
,
domStopped
public boolean domStopped
stop(_global_.Map)
,
stopped
,
auStopped
public void $init(Widget target, String name, Object data, Map opts, Event domEvent)
target
- the target widget.name
- the event name, such as onClickdata
- [optional] the data depending on the event.opts
- [optional] the options. Refer to opts
domEvent
- [optional] the DOM event that causes this widget event.public void addOptions(Map opts)
opts
.opts
- a map of options to append to #optspublic void stop(Map opts)
evt.stop();
evt.stop({propagation:true}); //stop only the event propagation (see below)
evt.stop({au:true}); //stop only the sending of the AU request
If you want to revoke the stop of the event propagation, you can specify {revoke:true} to the opts argument.
evt.stop({progagation:true,revoke:true}); //revoke the event propagation
Notice that the event won't be sent to the server if stop() was called.
opts
- [optional] control what to stop.
If omitted, the event propagation (stopped
) and the native DOM event (domStopped
) are both stopped
(but not auStopped
).
For fine control, you can use a combination of the following values:
stop(_global_.Map)
stopped
).domStopped
).auStopped
).
Notice that, unlike the propagation and dom options, the sending of AU requests won't be stopped if opts is omitted.
In other words, to stop it, you have to specify the au option explicitly. public boolean isPressed(String... The)
The
- target key and the modifier keyszKeys
Copyright © 2005-2023 Potix Corporation. All Rights Reserved.