The Mouseclick behavior is used to execute an action or JavaScriptâ„¢ function whenever a mouse button is clicked within a control or within a container tag. The scope of the binding depends on the kind of tag to which the behavior is assigned. If the behavior is bound to a container tag such as a form, div or body, then whenever the mouse is clicked within the container the action/function is run. If the behavior is bound to a non-container tag such as an input tag, then the binding applies only to clicks that occur within the control. Different browsers may have slightly different interpretations of what constitutes clicking "in" the control (e.g., whether clicking in the margins/border of a control constitutes clicking "in" it).The Mouseclick behavior is used to execute an action or JavaScript function whenever a mouse button is clicked within a control or within a container tag. The scope of the binding depends on the kind of tag to which the behavior is assigned. If the behavior is bound to a container tag such as a form, div or body, then whenever the mouse is clicked within the container the action/function is run. If the behavior is bound to a non-container tag such as an input tag, then the binding applies only to clicks that occur within the control. Different browsers may have slightly different interpretations of what constitutes clicking "in" the control (e.g., whether clicking in the margins/border of a control constitutes clicking "in" it).
When the button is clicked the function (if provided) is executed. If an action (or list of actions) is provided, the actions are executed next. If both a function and action are provided, the function can prevent execution of the action by returning false. In either case, the "default" behavior of the click is NOT executed. For example, if the right mouse button is bound, then when the button is clicked, the default browser behavior of displaying the context menu does not happen.
Assigning the mouseclick behavior to #body, specifying ALL as the button, and specifying the action NOTHING disables the mouse in the page.
<hx:behaviorRightMouse>
Any HTML container tag such as a <form> or <div> or any HTML tag that accepts mouse event such as <input>
Multiple Mouseclicks can be attached to a tag. Use #body as the tag to assign a click behavior to the entire page.
hX_5.addBehavior("id", "onmouse", new hX_5.JSFBehaviorMouseclick(attributes)); where
id |
The ID of the HTML tag to which the component is attached. |
attributes |
Comma separated list of attributes where each attribute is a quoted string consisting of the attribute name and value separated by a colon, for example "label:MyLabel". |
Event |
Description |
---|---|
onmouse |
Note the use of the special event name. The behavior modifies multiple mouse (and non-mouse) event handlers. |
Attribute name |
Description |
---|---|
button |
The mouse button to bind to. ALL means all buttons on the mouse. Note that the right mouse button may not exist (for example, on a MAC). |
action |
An action (or a set of actions) to be performed when a click-able entity is clicked. A target for the action (or a set of targets) are normally required. |
target |
If supplied, the ID of an input type='text' field in the page. Whenever something is selected in the menu, the text of the menu item is set as the value of the specified field. This is normally only used when making a popup menu which is emulating a combo-box (that is you have an input field with an adjacent menu where the top-level of the menu is a single button, clicking the button displays the menu, choosing an item from the menu sets the value of the input field.) |
function |
A JavaScript function (or inline string of JavaScript) to perform when the key is pressed. |
Runs after any other handlers provided for the event.
Stops the event continuing/bubbling after all the actions/function are executed.
API call |
Description |
---|---|
object = setAttribute(attribute) |
Sets an attribute or changes its value (if it was set previously). |
string = getAttribute(attribute-name) |
Retrieves the current value of an attribute. |
Within a page, disable the mouse.
hX.addBehavior("#body", "onmouse", new hX.JSFBehaviorMouseclick("scope:all", "action:nothing"));
Within a div, disable the right mouse button context menu and tell the user it's disabled.
hX.addBehavior("form1:div1", "onmouse", new hX.JSFBehaviorMouseclick("scope:right", "action:alert", "target:The context menu is disabled."));