Libraries.Web.Page.KeyboardAttributeAccepter Documentation

The KeyboardAttributeAccepter class is designed as a helper to ease adding and removing keyboard event attributes from particular WebTag objects. While there is no harm in creating an object of this type, it is used most commonly by sub-classes that need to use attributes. The example for this class shows how to subclass the KeyboardAttributeAccepter class.

Example Code

use Libraries.Web.Page.KeyboardAttributeAccepter

class Input is KeyboardAttributeAccepter, WebGenerator
    action Generate returns text
        text result = "<input " 
        Attributes attributes = parent:WebTag:GetAttributes()
        attributeText = attributes:Generate()
        result = result + attributeText + ">"
        result = result + me:GenerateNestedTags()
        result = result + "</input>"
        return result
    end
end

Inherits from: Libraries.Web.Page.AttributeAccepter, Libraries.Language.Object

Summary

Actions Summary Table

ActionsDescription
Add(Libraries.Web.Page.Attribute attribute)This action adds an attribute to this object.
AddAttribute(text name, text value)This action adds an attribute to this object.
Compare(Libraries.Language.Object object)This action compares two object hash codes and returns a CompareResult.
Equals(Libraries.Language.Object object)This action determines if two objects are equal based on their hash code values.
GenerateAttributes()This action returns a text description of all attributes stored.
GetAttribute(text name)This action returns an attribute from this object's Attributes object.
GetAttributeValue(text name)This action returns an attribute from this object's Attributes object.
GetAttributes()Returns a list of all attributes on the system.
GetHashCode()This action gets the hash code for an object.
GetIterator()This action returns an iterator of all attributes stored in this object.
GetNumberOfAttributes()This action returns the number of attributes that are currently stored in this object.
GetOnKeyDown()Returns the OnKeyDown attribute.
GetOnKeyPress()Returns the OnKeyPress attribute.
GetOnKeyUp()Returns the OnKeyUp attribute.
HasAttribute(text name)This action returns whether or not an attribute exists for the key passed in as a parameter.
RemoveAttribute(text name)This action removes an attribute with a particular key.
SetOnKeyDown(text value)Sets the OnKeyDown attribute.
SetOnKeyPress(text value)Sets the OnKeyPress attribute.
SetOnKeyUp(text value)Sets the OnKeyUp attribute.

Actions Documentation

Add(Libraries.Web.Page.Attribute attribute)

This action adds an attribute to this object. If an attribute with the same name as

Example Code

use Libraries.Web.Page.AttributeAccepter
        use Libraries.Web.Page.Attribute

        Attribute attribute
        attribute:SetName("src")
        attribute:SetValue("http://www.google.com")

        AttributeAccepter accept
        accept:Add(attribute)

Parameters

AddAttribute(text name, text value)

This action adds an attribute to this object. This action is a helper action, which essentially does the same thing as the Add(Attribute) action. If an attribute with the same name as

Example Code

use Libraries.Web.Page.AttributeAccepter
        use Libraries.Web.Page.Attribute

        AttributeAccepter accept
        accept:AddAttribute("src", "http://www.google.com")

Parameters

Compare(Libraries.Language.Object object)

This action compares two object hash codes and returns a CompareResult. The compare result is either larger if this hash code is larger than the object passed as a parameter, smaller, or equal.

Example Code

use Libraries.Language.Support.CompareResult
        Object o
        Object t
        CompareResult result = o:Compare(t)

Parameters

Return

Libraries.Language.Support.CompareResult: The Compare result, Smaller, Equal, or Larger.

Equals(Libraries.Language.Object object)

This action determines if two objects are equal based on their hash code values.

Example Code

use Libraries.Language.Object
        use Libraries.Language.Types.Text
        Object o
        Text t
        boolean result = o:Equals(t)

Parameters

Return

boolean: True if the hash codes are equal and false if they are not equal.

GenerateAttributes()

This action returns a text description of all attributes stored.

Example Code

use Libraries.Web.Page.AttributeAccepter
        use Libraries.Web.Page.Attribute

        AttributeAccepter accept
        accept:AddAttribute("src", "http://www.google.com")
        text result = accept:GenerateAttributes()

Return

text:

GetAttribute(text name)

This action returns an attribute from this object's Attributes object. If no attribute exists for a given key, this action returns undefined.

Example Code

use Libraries.Web.Page.AttributeAccepter
        use Libraries.Web.Page.Attribute

        AttributeAccepter accept
        //as we have not set any attribute, this would
        //return undefined
        Attribute attribute = accept:GetAttribute("src")

Parameters

Return

Libraries.Web.Page.Attribute:

GetAttributeValue(text name)

This action returns an attribute from this object's Attributes object. If no attribute exists for a given key, this action returns undefined.

Example Code

use Libraries.Web.Page.AttributeAccepter
        use Libraries.Web.Page.Attribute

        AttributeAccepter accept
        accept:AddAttribute("src", "http://www.google.com")
        //This helper action would throw an error if "src" were not set.
        text value = accept:GetAttributeValue("src")

Parameters

Return

text:

GetAttributes()

Returns a list of all attributes on the system.

Example Code

use Libraries.Web.Page.AttributeAccepter
        use Libraries.Web.Page.Attributes

        AttributeAccepter accept
        Attributes attributes = accept:GetAttributes()

Return

Libraries.Web.Page.Attributes: The attributes class contains all of the attributes that have been set for this object.

GetHashCode()

This action gets the hash code for an object.

Example Code

Object o
        integer hash = o:GetHashCode()

Return

integer: The integer hash code of the object.

GetIterator()

This action returns an iterator of all attributes stored in this object.

Example Code

use Libraries.Web.Page.AttributeAccepter
        use Libraries.Web.Page.Attribute
        use Libraries.Containers.Iterator

        AttributeAccepter accept
        accept:AddAttribute("src", "http://www.google.com")

        //output out all of the attributes
        Iterator<Attribute> it =  accept:GetIterator()
        repeat while it:HasNext()
            Attribute at = it:Next()
            output at:Generate()
        end

Return

Libraries.Containers.Iterator:

GetNumberOfAttributes()

This action returns the number of attributes that are currently stored in this object.

Example Code

use Libraries.Web.Page.AttributeAccepter
        use Libraries.Web.Page.Attribute

        AttributeAccepter accept
        accept:AddAttribute("src", "http://www.google.com")
        integer num = accept:GetNumberOfAttributes()

Return

integer:

GetOnKeyDown()

Returns the OnKeyDown attribute. If a key down event occurs on a specified element a script is fired based on this attribute.

Example Code

use Libraries.Web.Page.KeyboardAttributeAccepter
        use Libraries.Web.Page.Attribute

        KeyboardAttributeAccepter accept
        Attribute attribute = accept:GetOnKeyDown()

Return

Libraries.Web.Page.Attribute: The current OnKeyDown attribute.

GetOnKeyPress()

Returns the OnKeyPress attribute. If a key press event occurs on a specified element a script is fired based on this attribute.

Example Code

use Libraries.Web.Page.KeyboardAttributeAccepter
        use Libraries.Web.Page.Attribute

        KeyboardAttributeAccepter accept
        Attribute attribute = accept:GetOnKeyPress()

Return

Libraries.Web.Page.Attribute: The current OnKeyPress attribute.

GetOnKeyUp()

Returns the OnKeyUp attribute. If a key up event occurs on a specified element a script is fired based on this attribute.

Example Code

use Libraries.Web.Page.KeyboardAttributeAccepter
        use Libraries.Web.Page.Attribute

        KeyboardAttributeAccepter accept
        Attribute attribute = accept:GetOnKeyUp()

Return

Libraries.Web.Page.Attribute: The current OnKeyUp attribute.

HasAttribute(text name)

This action returns whether or not an attribute exists for the key passed in as a parameter.

Example Code

use Libraries.Web.Page.AttributeAccepter
        use Libraries.Web.Page.Attribute

        AttributeAccepter accept
        accept:AddAttribute("src", "http://www.google.com")
        //This helper action would throw an error if "src" were not set.
        boolean exists = accept:HasAttribute("src")

Parameters

Return

boolean:

RemoveAttribute(text name)

This action removes an attribute with a particular key. If that attribute does not exist, then this action returns undefined.

Example Code

use Libraries.Web.Page.AttributeAccepter
        use Libraries.Web.Page.Attribute

        AttributeAccepter accept
        accept:AddAttribute("src", "http://www.google.com")
        //This helper action would throw an error if "src" were not set.
        accept:RemoveAttribute("src")

Parameters

Return

Libraries.Web.Page.Attribute:

SetOnKeyDown(text value)

Sets the OnKeyDown attribute. If a key down event occurs on a specified element a script is fired based on this attribute.

Example Code

use Libraries.Web.Page.KeyboardAttributeAccepter
        use Libraries.Web.Page.Attribute

        KeyboardAttributeAccepter accept
        accept:SetOnKeyDown("doSomething()")

Parameters

SetOnKeyPress(text value)

Sets the OnKeyPress attribute. If a key press event occurs on a specified element a script is fired based on this attribute.

Example Code

use Libraries.Web.Page.KeyboardAttributeAccepter
        use Libraries.Web.Page.Attribute

        KeyboardAttributeAccepter accept
        accept:SetOnKeyPress("doSomething()")

Parameters

SetOnKeyUp(text value)

Sets the OnKeyUp attribute. If a key up event occurs on a specified element a script is fired based on this attribute.

Example Code

use Libraries.Web.Page.KeyboardAttributeAccepter
        use Libraries.Web.Page.Attribute

        KeyboardAttributeAccepter accept
        accept:SetOnKeyUp("doSomething()")

Parameters