We cover the following members of Sys.UI:
Sys.UI.Behavior
Sys.UI.Bounds
Sys.UI.DomElement
Sys.UI.DomEvent
Sys.UI.Key
Sys.UI.MouseButton
Sys.UI.Point
Sys.UI.VisibilityMode
Sys.UI.Behavior
class (Figure A-34) extends Sys.Component
and represents the base class for all behaviors.
Sys.UI.Bounds
class (Figure A-36) extends Sys .Component
and represents the base class for all controls.
Sys.UI.Bounds
class (Figure A-37) a set of methods for operating on a DOM element.
Static method that searches a DOM element by its ID.
id – the ID of the DOM element to be searched for.
element – optional DOM element that specifies parent element to search in.
If the DOM element to search in is not specified, the document
element is presumed by default.
Static method that add a CSS class to a DOM element.
Static method that checks to see if a DOM element has a specified CSS class.
Static method that removes a CSS class from a DOM element.
Static method that toggles a CSS class for a DOM element.
Static method that gets the position of the upper left corner for a DOM element.
Static method that gets the bounds for a DOM element.
The method returns a Sys.UI.Bounds
object containing the position and dimensions of the DOM element.
The method internally uses Sys.UI.DomElement.getLocation()
for the x
and y
fields of the Sys.UI.Bounds
object and the offsetWidth
and offsetHeight
attributes of the DOM element for the width
and height
fields of the same Sys.UI.Bounds
object.
For more information about the boxing model please check:
http://www.w3.org/TR/CSS21/box.html
Static method that sets the absolute position for a DOM element.
x – number of horizontal pixels from the top left corner.
y – number of vertical pixels from the top left upper corner.
The method internally sets the position
CSS attribute to absolute
and the left
and top
attributes to x
and y
.
Sys.UI.DomEvent
(Figure A-38) stores all the information that is passed to a handler registered to a DOM event and also provides methods for registering to a DOM event.
This enumeration contains the key codes.
Static method that adds a handler to an event of a DOM element.
element – the DOM element.
eventName – the name of the event the handler is being attached to.
handler – the handler to be attached to the DOM element’s event.
In the event handler, the this
keyword refers to the DOM element. Use Function. createDelegate()
to create handler delegates inside objects so that this refers the object and not the DOM element.
// Add a handler for the keypress event // Version 1 this._onKeyPressHandler = Function.createDelegate(this, this._ onKeyPress); $addHandler(this.get_element(),'keypress',this._ onKeyPressHandler); // Same as Sys.DomEvent.addHandler ... _onKeyPress: function(e){..} // Version 2 $addHandler(element, 'keypress', handler); function handler(e){..}
Static method that adds a series of handlers to different events of a DOM element.
element – the DOM element.
events – a JSON object containing pairs of event names and their handlers.
handlerOwner – if specified, this
will point to it inside event handlers.
There is no need to create delegates for the event handlers as with the addHandler()
. This method internally uses Function.createDelegate()
if handlerOwner
is specified.
This method could be used inside the initialize()
method of a component when a series of event handlers need to be attached.
Static method that removes all the event handlers attached to a DOM element.
This method should be used in the dispose()
method of a component in order to remove the attached event handlers.
Method that prevents the default event action from taking place.
Static method that removes an event handler from the DOM element it is attached to.
element – the DOM element.
eventName – the name of the event the handler is being removed from.
handler – the handler to be removed from the DOM element’s event.