vegui. std. prototypefix.jsSummary | | | | | holds pointers to all VegUIElement Constructor functions by their type | | | | | | Mouse and keyboard eventtypes that help you identify what event you’re dealing with | | Url needed for xmlhttprequest to work, can leave blank if working on a local server | | | | Bitmask flags that can be set on the flags property of each VegUIElement individually | | Resizes body to manager canvas size, this is to fix text selection and onmouseout in internet explorer | | Maximum element index possible, 90000 by default, increase if you need to spawn more than 90000 elements at the same time | | | | | | | | holds browser name in its name property | | | | Makes a vegUI module accessable by the manager. | | Internet explorer 6 leaks memory in closures, in order to fix that iesucks is called when the page is unloaded if the browser is ie6 | | Creates a new instance of a javascript object | | Attempt to append the properties of trgObj to srcObj | | | | checks if Node is the child of Parent somewhere up the parent chain | | | | Wrapper for document.createElement with the option to append the created node to another html node right away | | Wrapper for document.createElement to create an image node with the option to define proportions and image source right away | | Wrapper for document.createTextNode | | | | Handles a certain keyboard or mouse event type that gets triggered by the VegUIElement the VegUIMouseState belongs to | | | | | | | | (VegUIElement) VegUI element that owns this mouse state | | (int) holds the type of mouse or keyboard event this state handles | | | | (Array) properties that will be copied over to the element that owns this mouse state if the event that is handled by this mouse state is triggered | | The most basic VegUI Element. | | | | | | | | These properties are only set after certain mouse or keyboard events have been handled by this element | | Template properties are properties that will get turned into real properties when the node is built. | | | | | | | | | | | | Creates a VegUI element as a child of this element. | | Adds an existing VegUI Element to this element as a child | | Wrapper function to add a new vegui element to this element as a child with the ability to set the most common template properties | | (Re)Aligns all child elements of this element to their margins | | Attaches another VegUI element to this node. | | build a HTML node from the template properties of this element. | | This function triggers the ondock event on this element and all its child elements recursivly | | See if this element or any of its child elements has focus. | | Removes all child HTML nodes from the HTML node that is controlled by this element | | | | Clones the children and properties of a template element to this element | | clone multiple children that are of the same type from the same template | | Takes control over an existing HTML node | | Detaches an attached element that was attached to this element via attach_node. | | | | Appends the HTML node controlled by this element to another HTMLnode | | Adds a function to be executed to a vegui element event | | | | Add function to event listener of the node controlled by this element | | Find the first common vegui Parent that this element and Obj share | | | | | | toggles this element to be invisible or visible | | Checks if the HTML node controlled by this element is hidden or visible | | Check if a vegui element is the parent element of this element somewhere down the parent chain | | Removes the HTMLnode controlled by this element and/or destroys the element it self. | | Takes focus away from this element, the first parent that can have focus set on it will gain passive focus. | | moves the HTML node controlled by this element to new coordinates | | | | | | | | varies from element to element | | | | triggered when element gains focus | | triggered when element loses focus | | triggered after element was built | | | | Checks if this element overlaps with another element. | | resizes the HTML node controlled by this element | | Gives focus to the element. | | sets the height of the HTML node controlled by this element | | | | | | sets the CSS position of the HTML node controlled by this element | | Set the CSS transparency of the HTML node that is controlled by this element. | | sets the width of the HTML node controlled by this element | | repositions the HTML node controlled by this element on the x axis | | repositions the HTML node controlled by this element on the y axis | | Sticks the element to another element at a certain offset | | | | Removes the HTML node controlled by this element from its current parentNode. | | | | | | | | | | | | Spawns and keeps track of all vegUI elements | | | | | | | | | | | | | | | | Attempts the prevention of the default browser action for a certain keyboard key code | | | | builds multiple vegUI elements, if the last argument submitted to the function is a HTML node then the element’s will be built as children of that node | | | | clone multiple elements of the same template | | evals some javascript code | | Wrapper functions to create a new vegui element and clone it | | | | Creates a new VegUIElement | | Includes javascript code from a file and executes is | | initializes common VegUIBridge object that can be accessed by all spawned VegUIElements by accessing it over their Manager property | | initializes common VegUIFXManager object that can be accessed by all spawned VegUIElements by accessing it over their Manager attribute | | Check if a keycode has been blocked with <block_key> | | | | Removes a keycode block set by <block_key> method | | Bounding box for elements, limits where an element can be moved to. | | | | | | | | | | checks if the element is within the boundin box’s border, if not the element will be moved to be within the bounding box’s border | | | | Validates the position of the element that the bounding box belongs to | | Allows to have a function with dynamic content | | | | | | | | | | Adds a function to the stack | | Executes all the functions in the stack | | Free a unique function id effectivly removing the function linked to it from the stack |
VEGUIOBJholds pointers to all VegUIElement Constructor functions by their type
Mouse and keyboard event typesMouse and keyboard eventtypes that help you identify what event you’re dealing with | VUI_MOUSE_DOWN | mouse button clicked on the vegUI element | | VUI_MOUSE_UP | mouse button released on the vegUI element | | VUI_MOUSE_OVER | mouse button entered the vegUI element | | VUI_MOUSE_OUT | mouse button leaves the vegUI element | | VUI_MOUSE_MOVE | mouse moved within the borders of vegUI element | | VUI_MOUSE_WHEEL | mouse wheel used | | VUI_KEY_DOWN | keyboard key pressed | | VUI_KEY_UP | keyboard key released | | VUI_FORM_BLUR | onblur event in form elements | | VUI_FORM_FOCUS | onfocus event in form elements | | VUI_MOUSE_DBL_LICK | dbclick event |
VUI_URLUrl needed for xmlhttprequest to work, can leave blank if working on a local server
Generic directions| VUI_UP | up | | VUI_DOWN | down | | VUI_LEFT | left | | VUI_RIGHT | right | | VUI_BACK | back | | VUI_FRONT | front |
Flags, CommonBitmask flags that can be set on the flags property of each VegUIElement individually | VUI_HMOUSE_UP | enable event handling for VUI_MOUSE_UP | | VUI_HMOUSE_DOWN | enable event handling for VUI_MOUSE_DOWN | | VUI_HMOUSE_OVER | enable event handling for VUI_MOUSE_OVER | | VUI_HMOUSE_OUT | enable event handling for VUI_MOUSE_OUT | | VUI_HMOUSE_MOVE | enable event handling for VUI_MOUSE_MOVE | | VUI_HMOUSE_WHEEL | enable event handling for VUI_MOUSE_WHEEL | | VUI_HMOUSE_DBL_CLICK | enable envent handling for VUI_MOUSE_DBL_CLICK | | VUI_HKEY_DOWN | enable event handling for VUI_KEY_DOWN | | VUI_HKEY_UP | enable event handling for VUI_KE_UP | | VUI_TEMPLATE | flag VegUIElement as template prohibting it from being built | | VUI_DISABLED | flag VegUIElement as being disabled, prohibiting any event handling |
ADJUST_BODY_SIZEResizes body to manager canvas size, this is to fix text selection and onmouseout in internet explorer
ELEMENT_MAX_INDEXMaximum element index possible, 90000 by default, increase if you need to spawn more than 90000 elements at the same time
Focus types| VUI_FOCUS_PASSIVE | passive focus | | VUI_FOCUS_ACTIVE | active focus |
Mouse coordinates| mouseX | absolute x coordinate of the mouse pointer | | mouseY | absolute y coordinate of the mouse pointer |
VUI_BROWSER_INFOholds browser name in its name property
vui_module_add| function vui_module_add( | type, | | module, | | filename | ) |
|
Makes a vegUI module accessable by the manager. When developing addons for vegUI make sure you initialize your module using this function instead of adding it’s type directly to the VEGUIOBJ array. If there are colliding types an error message will be displayed and the script is halted Added in2.0.6 Parameters| int type | unique type id of the module | | func module | constructor function of the module | | string filename | filename that the function was called in |
Returns| bool | true on success | | bool | false on error |
Examplevui_module_add(VUI_NODE, VegUINode, 'vegui.std.js');
iesucks| var browser_str = navigator.userAgent.toLowerCase( | | ); function iesucks(Node) |
|
Internet explorer 6 leaks memory in closures, in order to fix that iesucks is called when the page is unloaded if the browser is ie6 Parameters| Node | HTML Node that needs to have events reset recursivly |
CloneCreates a new instance of a javascript object Parameters| Object Obj | object to be cloned |
ExampleIn this example newObj will be an exact clone of Obj var newObj = new Clone(Obj);
merge| function merge( | srcObj, | | trgObj | ) |
|
Attempt to append the properties of trgObj to srcObj Parameters| Object trgObj | Javascript Object | | Object srcObj | Javascript Object |
ExampleAny non-existing properties of Obj2 will be copied to Obj1, existing properties will be overwritten merge(Obj1, Obj2);
cloneArrayclones an array Parameters| Array Arr | Array to be cloned |
ReturnsExamplenewArr will be an exact copy of oldArr var newArrr = cloneArray(oldArr);
has_parent| function has_parent( | Node, | | Parent | ) |
|
checks if Node is the child of Parent somewhere up the parent chain Parameters| HTMLNode Node | HTML Node | | HTMLNode Parent | HTML Node |
Returns| bool | true if Parent is the parent node of Node directly or indirectly | | bool | false if Parent is not the parent node of Node directly or indirectly |
Examplevar node1 = document.createElement('div'); var node2 = document.createElement('div'); var node3 = document.createElement('div'); node1.appendChild(node2); node2.appendChild(node3);
return has_parent(node2, node1);
return has_parent(node3, node1);
get_mouseget mouse pointer location, sets mouseX and mouseY ParametersExamplenode.onmousemove = function(e) { get_mouse((e ? e : event)); alert(mouseX+','+mouseY); }
htmlnode| function htmlnode( | nodeName, | | parentNode | ) |
|
Wrapper for document.createElement with the option to append the created node to another html node right away Paramters| string nodeName | html name of the node (ie. ‘div’) | | <HTMLNode parentNode> | created html node will be appended to this node |
Returns
imgnode| function imgnode( | src, | | w, | | h, | | parentNode | ) |
|
Wrapper for document.createElement to create an image node with the option to define proportions and image source right away Parameters| string src | path of the image | | int w | width of the image (pixels) | | int h | height of the image (pixels) | | <HTMLNode parentNode> | created image node will be appened to this node |
Returns
txtnodeWrapper for document.createTextNode Parameters| string txt | text string to be created |
Returns
vui_rand| function vui_rand( | min, | | max | ) |
|
generate a random number Parameters| int min | minimum number | | int max | maximum number |
Returns| int | the generated number (int) |
Examplevar n = vui_rand(1,30);
VegUIMouseStateHandles a certain keyboard or mouse event type that gets triggered by the VegUIElement the VegUIMouseState belongs to Summary | | | | | | | (VegUIElement) VegUI element that owns this mouse state | | (int) holds the type of mouse or keyboard event this state handles | | | | (Array) properties that will be copied over to the element that owns this mouse state if the event that is handled by this mouse state is triggered |
VegUIMouseState| function VegUIMouseState( | eventType, | | Parent | ) |
|
Parameters
Parent(VegUIElement) VegUI element that owns this mouse state
type(int) holds the type of mouse or keyboard event this state handles
Properties(Array) properties that will be copied over to the element that owns this mouse state if the event that is handled by this mouse state is triggered
VegUINodeThe most basic VegUI Element. The VegUINode is the base element for every other vegUI element. Summary | | | | | | | These properties are only set after certain mouse or keyboard events have been handled by this element | | Template properties are properties that will get turned into real properties when the node is built. | | | | | | | | | | | | Creates a VegUI element as a child of this element. | | Adds an existing VegUI Element to this element as a child | | Wrapper function to add a new vegui element to this element as a child with the ability to set the most common template properties | | (Re)Aligns all child elements of this element to their margins | | Attaches another VegUI element to this node. | | build a HTML node from the template properties of this element. | | This function triggers the ondock event on this element and all its child elements recursivly | | See if this element or any of its child elements has focus. | | Removes all child HTML nodes from the HTML node that is controlled by this element | | | | Clones the children and properties of a template element to this element | | clone multiple children that are of the same type from the same template | | Takes control over an existing HTML node | | Detaches an attached element that was attached to this element via attach_node. | | | | Appends the HTML node controlled by this element to another HTMLnode | | Adds a function to be executed to a vegui element event | | | | Add function to event listener of the node controlled by this element | | Find the first common vegui Parent that this element and Obj share | | | | | | toggles this element to be invisible or visible | | Checks if the HTML node controlled by this element is hidden or visible | | Check if a vegui element is the parent element of this element somewhere down the parent chain | | Removes the HTMLnode controlled by this element and/or destroys the element it self. | | Takes focus away from this element, the first parent that can have focus set on it will gain passive focus. | | moves the HTML node controlled by this element to new coordinates | | | | | | | | varies from element to element | | | | triggered when element gains focus | | triggered when element loses focus | | triggered after element was built | | | | Checks if this element overlaps with another element. | | resizes the HTML node controlled by this element | | Gives focus to the element. | | sets the height of the HTML node controlled by this element | | | | | | sets the CSS position of the HTML node controlled by this element | | Set the CSS transparency of the HTML node that is controlled by this element. | | sets the width of the HTML node controlled by this element | | repositions the HTML node controlled by this element on the x axis | | repositions the HTML node controlled by this element on the y axis | | Sticks the element to another element at a certain offset | | | | Removes the HTML node controlled by this element from its current parentNode. | | | | | | | | | | |
Object Properties| refName | string, name of the object | | Parent | VegUIElement, Parent element of this element | | Manager | VegUIElement, Manager element that spawned this element | | type | int, element type VUI_NODE | | C | Alias for Childs | | Childs | Object, Holds all child elements of this type by their element index | | T | Alias for Template | | Template | Object, Holds template properties | | Base | HTMLNode, Holds the HTML node that is controlled by the element | | Css | DOMNode, Holds the style property of the HTML node that is controlled by this element | | hasFocus | int, Holds the focus type of the node | | flags | int, Bitmask | | BBox | VegUIBBox, Holds the Bounding Box object of this element | | transparency | int, Holds the transparency value of this element (0-100) | | States | Array, Holds mouse/keyboard event states, one state for each event type | | nodeId | string, Holds the id of the HTML node that is controlled | | noAutoShow | bool, prevents the element from being flagged visible recursivly | | childName | string, child name of the node | | lockFocus | bool, if true focus can never be taken away from this node | | Attached | array, array holding vegui elements that were attached to this element via attach_node |
Event Specific Object PropertiesThese properties are only set after certain mouse or keyboard events have been handled by this element | mEvent | Event, Holds the javascript event object for the last mouse or key event handled by this node | | delta | int, Mousewheel delta, is set whenever the mousewheel event is handled by this element | | aKey | int, character code of the last key down or key up event handled by this element | | aKeyChar | char, character of the last key down or key up event handled by this element | | toE | HTMLNode, relatedTarget / toElement from the last mouse event handled by this element | | keyShift | bool, if true then shift key was held down when the last keyboard event was handled by this element | | keyAlt | bool, if true then the alt key was held down when the last keyboard event was handled by this element | | keyCtrl | bool, if true then the ctrl key was held down when the last keyboard event was handled by this element |
Template PropertiesTemplate properties are properties that will get turned into real properties when the node is built. They are stored in the Template property of the element | T.nodeType | string, node type of the htmli node to be built (ie ‘div’) | | T.x | int, node position on the x axis (pixels) | | T.y | int, node position on the y axis (pixels) | | T.w | int, node width (pixels) | | T.h | int, node height (pixels) | | T.rmarg | int, right margin | | T.bmarg | int, bottom margin | | T.rmarg_nr | int, right margin, no resize | | T.bmarg_nr | int, bottom margin, no resize | | T.micon | string, mouse cursor to use when the mouse enters the element (CSS cursor attribute) | | T.blockIETransparency | bool, if true any transparency effects will be ignored if the browser is internet explorer | | T.img_src | string, will set the HTML node’s src attribute | | T.Css | Object, any properties in T.Css will be copied to the HTML node’s style property | | T.innerHtml | string, The HTML Node’s innerHTML attribute will be set to this, if set | | T.type | string, The HTML Node’s type attribute will be set to this if set | | T.className | string, The HTML node will be using this CSS class if set |
VegUINode| function VegUINode( | refName, | | Parent, | | Manager | ) |
|
Parameters| string refName | name of the object | | VegUIElement Parent | Parent element of this element | | VegUIElement Manager | Manager element that spawned this element |
abs_middle| this.abs_middle = function( | stopAt | ) |
|
Parameters| <HTMLNode stopAt> | if submitted, the absolute position will be returned relative to the submitted node |
Returns| Array | array holding x and y coordinates of the abolute middle of the HTML node controlled by this element |
See alsoabs_x, abs_y, x, y
abs_x| this.abs_x = function( | stopAt | ) |
|
Parameters| <HTMLNode stopAt> | if submitted, the absolute position will be returned relative to the submitted node |
Returns| int | the absolute position of the HTML node controlled by this element on the x axis | | null | if no HTML node is controlled by this element |
See alsoabs_y, abs_middle, x, y
abs_y| this.abs_y = function( | stopAt | ) |
|
| <HTMLNode stopAt> | if submitted, the absolute position will be returned relative to the submitted node |
Returns| int | the absolute position of the HTML node controlled by this element on the y axis | | null | if no HTML node is controlled by this element |
See alsoabs_x, abs_middle, x, y
add_child| this.add_child = function( | name, | | type, | | nodeName, | | pos | ) |
|
Creates a VegUI element as a child of this element. Childs can be accessed over the Child or C property of this element by their unique child name Parameters| string name | unique child name | | int type | <VegUI element types> | | <string nodeName> | if set the childs T.nodeType property will be set to this | | <string pos> | if set the childs T.pos property will be set to this (Css position value, ie ‘absolute’) |
Returns| VegUIElement | the created element |
See alsoadd_skin, add_child_o Examplevar c = myNode.add_child('mychild', VUI_NODE, 'div', 'absolute');
add_child_o| this.add_child_o = function( | name, | | Obj | ) |
|
Adds an existing VegUI Element to this element as a child Parameters| string name | unique child name | | VegUIElement Obj | element to add as a child |
See alsoadd_child, add_skin Examplevar node1 = Manager.get_new(VUI_NODE); var node2 = Manager.get_new(VUI_NODE); node2.add_child_o(node1);
add_skin| this.add_skin = function( | n, | | w, | | h, | | x, | | y, | | c, | | rm, | | bm, | | rm_nr, | | bm_nr, | | nN, | | i | ) |
|
Wrapper function to add a new vegui element to this element as a child with the ability to set the most common template properties Parameters| string n | node name (ie ‘div’) | | int w | width (pixels) | | int h | height (pixels) | | int x | position on x axis (pixels) | | int y | position on y axis (pixels) | | string className | sets the T.className property (css class to use) | | int rm | right margin (pixels) | | int bm | bottom margin (pixels) | | int rm_nr | right margin no resize (pixels) | | int bm_nr | bottom margin no resize (pixels) | | string nN | node name ie ‘div’ | | string i | image source (file path) |
Returns| VegUIElement | the created element |
See alsoadd_child, add_child_o
align_childs| this.align_childs = function( | Child | ) |
|
(Re)Aligns all child elements of this element to their margins Parameters| VegUIElement <Child> | if submitted only this child will be realigned |
See alsoset_marg
attach_node| this.attach = this.attach_node = function( | Element, | | offsetX, | | offsetY, | | direction, | | z | ) |
|
Attaches another VegUI element to this node. When an element is attached it will stick to this node and move with it whenever it is moved Alias<attach> Parameters| VegUIElement Element | the element you want to attach to this node | | int offsetX | x offset | | int offsetY | y offset | | <int direction> | can be set to VUI_BACK or VUI_FRONT and will overwrite the z-index value of the attached element | | <int z> | z offset (default = 1) |
See alsodetach_node Example myNode.attach(yourNode, 5, 5, VUI_BACK, 2);
build_node| this.build = this.build_node = function( | toNode, | | takeNode | ) |
|
build a HTML node from the template properties of this element. Once the node is built it will be controlled by this element Aliasbuild() Parameters| HTMLNode toNode | if submitted the created HTMLnode will be appended as a child to this node | | <HTMLNode takeNode> | instead of creating a new HTMLnode an existing one will be taken over |
Returns| int | 1 on success | | null | on failure |
call_ondock| this.call_ondock = function() |
This function triggers the ondock event on this element and all its child elements recursivly
check_focus| this.check_focus = function( | focusType | ) |
|
See if this element or any of its child elements has focus. Parameters| <int focusType> | if submitted the function checks if the element has focus of the submitted type |
Returns| int | focus type if element has focus | | int | 0 if no focus is found |
See alsoset_focus_node, lose_focus_node
clear| this.clear = function( | replacement | ) |
|
Removes all child HTML nodes from the HTML node that is controlled by this element Parameters| <HTMLNode replacement> | Optional node to be added to the HTML node controlled by this element after clearing. |
See alsokill ExamplemyNode.clear();
myNode.clear(htmlnode('div'));
clone_event| this.clone_event = function( | Template | ) |
|
Clones a vegUI event Paramters| var event | can hold a VegUIDynFunc object or a generic function |
Returns
clone_node| this.clone = this.clone_node = function( | Template | ) |
|
Clones the children and properties of a template element to this element Template elements are vegUI elements that have not been built. Aliasclone() Parameters| VegUIElement Template | Template element to clone from |
ReturnsExample yourNode.clone(myNode);
clone_children| this.clone_children = function( | type, | | T, | | rec | ) |
|
clone multiple children that are of the same type from the same template Parameters| int type | vegui type of the children (eg <VUI_NODE)) | | vegUIElement T | template to clone from | | <bool rec> | if true children will be cloned recursively, else only direct children of this element will be cloned (default: false) |
control| this.control = function( | Node | ) |
|
Takes control over an existing HTML node Parameters| HTMLNode Node | HTML node to take control over |
ReturnsExample myNode.control(document.getElementById('some_element')); myNode.move(50,50);
detach_node| this.detach_node = this.detach = function( | Element | ) |
|
Detaches an attached element that was attached to this element via attach_node. Aliasdetach() Parameters| VegUIElement Element | element you want to detach |
See alsoattach_node ExamplemyNode.attach(yourNode); myNode.detach(yourNode);
disable_node| this.disable = this.disable_node = function( | b | ) |
|
Toggles the VUI_DISABLED flag on this element Aliasdisable() Parameters| bool b | if true flag is toggled on, if false flag is toggled off |
dock| this.dock = function( | toNode, | | insertBefore | ) |
|
Appends the HTML node controlled by this element to another HTMLnode Parameters| HTMLNode toNode | the HTMLNode that shall serve as a parent |
See alsoundock ExamplemyNode.dock(document.body);
event_add| this.event_add = function( | eventName, | | func, | | funcId | ) |
|
Adds a function to be executed to a vegui element event Parameters| string eventName | name of the target event | | function func | function to be executed on the event | | <var funcId> | optional unique id of the function |
See alsoevent_execute ExamplemyNode.event_add('onresize', function() { alert('test'); });
event_execute| this.event_execute = function( | eventName, | | args | ) |
|
Fires a vegUI event Parameters| string eventName | name of the event | | <array args> | arguments |
See alsoevent_execute
event_listener_set| this.event_listener_set = function( | eventName, | | func, | | n | ) |
|
Add function to event listener of the node controlled by this element Parameters | string eventName | name of the event (ie. ‘onclick’ or ‘onmousedown’) | | function func | function to be added | | <HTMLNode n> | if submitted the event listener will be added to this node instead of the node controlled by the element |
find_common_parent| this.find_common_parent = function( | Obj | ) |
|
Find the first common vegui Parent that this element and Obj share Parameters| VegUIElement Obj | VegUI element |
Returns| VegUIEleemnt | parent element if one is found | | null | if no parent element is found |
See alsois_parent Examplevar node1 = existingNode.add_child('node1', VUI_NODE); var node2 = existingNode.add_child('node2', VUI_NODE); var node3 = node2.add_child('node3', VUI_NODE);
return node3.find_common_parent(node1);
heightReturns| int | the height of the HTML node controlled by this element | | null | if no HTML node is currently controlled |
See alsowidth, x, y, x2, y2
hevent_node| this.hevent = this.hevent_node = function( | eventType, | | mEvent | ) |
|
private function This function gets called whenever a mouse or keyboard event is handled by this element.It executes all the functions stored in the VegUIMouseState State property of this element for the event in question and sets the event specific properties. Aliashevent() ParametersReturns| bool | returnVal property of the Scripts property of the affected VegUIMouseState |
See alsotgl_event
hidetoggles this element to be invisible or visible Parameters| bool b | if true the element will be made invisible, if false the element will be made visible |
See alsois_hidden ExamplemyNode.hide(1); // node is hidden myNode.hide(0); // node is visible again
is_hidden| this.is_hidden = function() |
Checks if the HTML node controlled by this element is hidden or visible Returns| bool | true if hidden | | bool | false if visible |
See alsohide ExamplemyNode.hide(1); return myNode.is_hidden(); // returns true
is_parent| this.is_parent = function( | Obj | ) |
|
Check if a vegui element is the parent element of this element somewhere down the parent chain Parameters| VegUiElement Obj | VegUI element to check |
Returns| int | 1 if Obj is the parent of this element | | int | 0 if Obj is not the parent of this element |
See alsofind_common_parent ExamplemyNode = pNode.add_child('myNode', VUI_NODE); return myNode.is_parent(pNode); // returns true
kill| this.kill = function( | removeSelf, | | keepBase | ) |
|
Removes the HTMLnode controlled by this element and/or destroys the element it self. The onkill event is called by this function Parameters | bool removeSelf | if true this element will be unlinked from the manager and destroyed | | bool keepBase | if true the HTML node controlled by this element will not be destroyed |
See alsoclear ExamplemyNode.kill(); // only the html node is removed from the document myNode.kill(1); // html node is removed from the document and element is destroyed myNode.kill(1,1); // only the vegui element is destroyed
lose_focus_node| this.lose_focus = this.lose_focus_node = function( | bail | ) |
|
Takes focus away from this element, the first parent that can have focus set on it will gain passive focus. Aliaslose_focus() Paramters| <bool bail> | if true the next focusable parent of this child will not gain focus |
See alsoset_focus_node, check_focus
move| this.move = function( | x, | | y | ) |
|
moves the HTML node controlled by this element to new coordinates Parameters| int x | new x position (pixels) | | int y | new y position (pixels) |
See alsoset_x, set_y ExamplemyNode.move(5, 15);
onmovecalled when the element is moved via the set_x, set_y or move methods
onchangevaries from element to element
onfocussettriggered when element gains focus
onfocuslosetriggered when element loses focus
onbuildtriggered after element was built
overlaps| this.overlaps = function( | Node, | | yDiffS, | | yDiffT | ) |
|
Checks if this element overlaps with another element. Overlapping meaning they collide somewhere and one is covered by the other. Be aware that this function only checks coordinates, it does not matter if the two nodes arent children of the same parent node, if their coordinates and proportions collide - even in theory - the function will return the overlapping percentage. Parameters| VegUIElement Node | vegui element to check against | | <int yDiffS> | experimental manipulate y position of this element | | <int yDiffT> | experimental manipulate y position of Node |
Returns| int | overlapping percentage value is returned (0-100) |
resize| this.resize = function( | w, | | h, | | noAlign | ) |
|
resizes the HTML node controlled by this element Parameters| int w | width (pixels) | | int h | height (pixels) | | bool noAlign | if true align_childs method will not be called |
See alsoset_width, set_height
set_focus_node| this.set_focus = this.set_focus_node = function( | focusType | ) |
|
Gives focus to the element. When an element has focus the manager that spawned that element knows where to direct certain keyboard and mouse events to Aliasset_focus() Parametersint focusType = Focus types Returns| int | 1 | | int | 0 if focs is currently on a node that has it’s lockFocus property set to true |
See alsolose_focus_node, check_focus
set_height| this.set_height = function( | n, | | noAlign | ) |
|
sets the height of the HTML node controlled by this element Parameters| int n | height (pixels) | | bool noAlign | if true the align_childs method will not be called |
See alsoset_width, resize
set_marg| this.set_marg = function( | rmarg, | | bmarg, | | rmarg_nr, | | bmarg_nr | ) |
|
Template Function Sets the margins of this element in relation to the proportions of it’s parent element Parameters| int rmarg | right margin (pixels) | | int bmarg | bottom margin (pixels) | | int rmarg_nr | right margin , no resize - node will be moved to meet margin (pixels) | | int bmarg_nr | bottom margin, no resize - node will be moved to meet margin (pixels) |
Code ExampleThis would resize this element whenever the proportions of it’s parents change to leave a space of 5 pixels between the element’s right and bottom border and the parent’s right and bottom border myNode.set_marg(5,5);
See also<set>, set_node, align_childs
set_node| this.set = this.set_node = function( | nodeType, | | w, | | h, | | x, | | y, | | pos, | | z | ) |
|
Template Function Sets the most common template properties for this element. Properties will only be (re)set if valid values are submitted. So if you do wish to ommit certain properties submit them as null Aliasset() Parameters| string nodeType | HTML tag name (ie ‘div’) | | int w | width (pixels) | | int h | height (pixels) | | int x | position on the x axis (pixels) | | int y | position on the y axis (pixels) | | string pos | CSS position (ie ‘absolute’), default = ‘absolute’ | | int z | z index |
See alsoset_marg ExamplemyNode.set('div', 50, 50, 5, 5, 'absolute', 15); Manager.build_element(myNode);
set_pos| this.set_pos = function( | pos, | | n | ) |
|
sets the CSS position of the HTML node controlled by this element Parameters| string pos | css position value (ie ‘absolute’) | | int n | z index |
ExamplemyNode.set_pos('absolute', 15);
set_transparency| this.set_transparency = function( | n, | | noIe | ) |
|
Set the CSS transparency of the HTML node that is controlled by this element. Parameters| int n | transparency value (percent, 0- 100) | | bool noIe | deprecated |
ExamplemyNode.set_transparency(50); // 50% transparent
set_width| this.set_width = function( | n, | | noAlign | ) |
|
sets the width of the HTML node controlled by this element Parameters| int n | width (pixels) | | bool noAlign | if true the align_childs method will not be called |
See alsoset_height, resize
set_xrepositions the HTML node controlled by this element on the x axis ParametersSee alsoset_y, move
set_yrepositions the HTML node controlled by this element on the y axis ParametersSee alsoset_x, move
stick| this.stick = function( | toElement, | | offsetX, | | offsetY, | | direction, | | offsetZ | ) |
|
Sticks the element to another element at a certain offset Parameters| VegUIElement toElement | element to stick to | | int offsetX | x axis offset (px) | | int offsetY | y axis offset (px) | | int direction | VUI_FRONT or VUI_BACK | | int offsetZ | z offset |
tgl_event| this.tgl_event = function( | b, | | eventType, | | nodeProp, | | ret | ) |
|
private function Toggles event handling for a certain mouse or keyboard event on or off. This function is called automatically by the <build> method if the flags property of this element has event handling enabled for a certain keyboard or mouse event Parameters| bool b | toggle on or off (true / false) | | int eventType | Mouse and keyboard event types | | string nodeProp | dom event name (ie onmousemove for VEGUI_MOUSE_MOVE) | | bool ret | this will be returned by the mouse event on the node |
See alsohevent_node
undockRemoves the HTML node controlled by this element from its current parentNode. Returns| HTMLNode | the parentNode the HTML node was attached to |
See alsodock ExamplemyNode.dock(document.body); myNode.undock();
widthReturns| int | the width of the HTML node controlled by this element | | null | if no HTML node is currently controlled |
See alsoheight, x, y, x2, y2
xReturns| int | the x position of the HTML node controlled by this element | | null | if no HTML node is controlled by this element |
See Alsoy, x2, y2, abs_x, abs_y
x2Returns| int | the right position of the HTML node controlled by this element | | null | if no HTML node is controlled by this element |
See alsoy2, x, y, abs_x, abs_y
yReturns| int | the y position of the HTML node controlled by this element | | null | if no HTML node is controlled by this element |
See alsox, x2, y2, abs_x, <abs y>
y2Returns| int | the bottom position of the HTML node controlled by this element | | null | if no HTML node is controlled by this element |
See alsox2, x, y, abs_x, abs_y
VegUIManagerSpawns and keeps track of all vegUI elements Summary | | | | | | | | | | | | | | | Attempts the prevention of the default browser action for a certain keyboard key code | | | | builds multiple vegUI elements, if the last argument submitted to the function is a HTML node then the element’s will be built as children of that node | | | | clone multiple elements of the same template | | evals some javascript code | | Wrapper functions to create a new vegui element and clone it | | | | Creates a new VegUIElement | | Includes javascript code from a file and executes is | | initializes common VegUIBridge object that can be accessed by all spawned VegUIElements by accessing it over their Manager property | | initializes common VegUIFXManager object that can be accessed by all spawned VegUIElements by accessing it over their Manager attribute | | Check if a keycode has been blocked with <block_key> | | | | Removes a keycode block set by <block_key> method |
Hierarchyextends vegUINode VegUINode | | +-- VegUIManager
TypeVUI_MANAGER
Child Elements| WinShadow | VUI_NODE, Window ‘shadow’ that the user sees while resizing or dragging window elements |
Object Properties| eleIdx | int, element index counter | | winIdx | int, special index counter for elements of type VUI_WIN | | Elements | Array, Holds all currently spawned elements | | Windows | Array Holds all currently spawned windows | | Bridge | VegUIBridge, common VegUIBridge object, null until init_bridge method is called | | VegUIFX FX | VegUIFXManager, common VegUIFXManager object, null until init_fx method is called | | VegUITaskbar Taskbar | link to a taskbar element that shell hold the windows spawned by this manager |
VegUIManager| function VegUIManager( | refName | ) |
|
Constructor Parameters| string refName | name of the object |
block keyAttempts the prevention of the default browser action for a certain keyboard key code Paramters| array keyCode | key codes to block |
See alsounblock_key Example Manager.block_key([37,38,39,40]);
build_element| this.build_element = function( | VegUIObj, | | toNode | ) |
|
builds a VegUIElement. This is the function that should be used to build vegui elements, instead of calling the element’s build method whenever possible Parameters| VegUIElement VegUIObj | vegui element to build | | <HTMLNode toNode> | if submitted the html node will be appended to toNode |
Returns| int | 1 on success | | int | 0 on failure |
See alsobuild_elements, VegUINode::build_node ExamplemyNode = Manager.get_new(VUI_NODE); myNode.set('div',50,50); myNode.T.Css.backgroundColor = 'black'; Manager.build_element(myNode);
build_elements| this.build_elements = function() |
builds multiple vegUI elements, if the last argument submitted to the function is a HTML node then the element’s will be built as children of that node Added in2.0.6 Parameters| VegUIElement ... | VegUIElement to be built | | <HTMLNode toNode> | if submitted the elements will be built as children of this node |
See alsobuild_element Example Manager.build_elements(myNode, myNode2, myNode3, document.body);
build_manager| this.build = this.build_manager = function( | toNode, | | takeBody | ) |
|
builds the manager Aliasbuild() Parameters| <HTMLNode toNode> | if submitted the created HTML node will be appended to toNode | | <bool takeBody> | instead of building a new node, the manager will take over the body element instead. |
Returns| null | on failure | | int | 1 on success |
See alsoVegUINode::build_node
clone_elements| this.clone_elements = function( | T | ) |
|
clone multiple elements of the same template Parameters| VegUIElement T | the template you wish to clone from | | VegUIElement ... | elements |
ExampleManager.clone_elemebnts(myTemplate, myNode, myNode2);
evalme| this.evalme = function( | code | ) |
|
evals some javascript code Parameters| string code | code to evaluate |
get_clone| this.get_clone = function( | Template, | | Parent | ) |
|
Wrapper functions to create a new vegui element and clone it Parameters| VegUIElement Template | template element to clone from | | <VegUIElement Parent> | parent of the created element |
Returns| VegUIElement | the created element |
See alsoget_new ExamplemyNode = Manager.get_new(VUI_NODE); myNode2 = Manager.get_clone(myNode);
get_free_idx| this.get_free_idx = function() |
private function Returns a free element index, which is a ranom unused number between 0 and ELEMENT_MAX_INDEX Returns| int | unused element index number | | null | if no unused element index number could be found |
get_new| this.get_new = function( | type, | | Parent, | | Template | ) |
|
Creates a new VegUIElement Parameters| int type | <VegUI Element Types> | | <VegUIElement Parent> | Parent element of the element to be created | | <VegUIElement Template> | Template to clone the element from |
NoteThis is the function that should be used to create new vegui elements that are not the children of other vegui elements. Returns| VegUIElement | the created vegui element |
See alsoget_clone ExamplemyNode = Manager.get_new(VUI_Node);
include| this.include = function( | path, | | ondone, | | async | ) |
|
Includes javascript code from a file and executes is RequiresParameters| string path | relative file path | | <function ondone> | function to execute when the include is done | | <bool async> | if true, server request will be async to the execution of the script allowing the execution of the script to continue while the request is being sent |
ExampleManager.init_bridge(); // only needs to be called once, not everytime Manager.include('helloworld.js');
init_bridge| this.init_bridge = function() |
initializes common VegUIBridge object that can be accessed by all spawned VegUIElements by accessing it over their Manager property Requiresvegui.bridge.class.js myNode.Manager.Bridge.dostuff()
ReturnsSee alsoinit_fx ExampleManager.init_bridge(); Manager.Bridge.send('somefile.txt', '', 'GET');
init_fx| this.init_fx = function( | interval | ) |
|
initializes common VegUIFXManager object that can be accessed by all spawned VegUIElements by accessing it over their Manager attribute Requiresvegui.fx.class.js myNode.Manager.FX.dostuff()
Parameters| int interval | fx timer interval (ms) |
ReturnsSee alsoinit_bridge
key_is_blocked| this.key_is_blocked = function( | keyCode | ) |
|
Check if a keycode has been blocked with <block_key> Parameters| int keyCode | key code to check |
Returns| bool | true if key is blocked | | bool | false if key is not blocked |
See also<block_key>, unblock_key ExampleManager.block_key([38]); return Manager.key_is_blocked(38); // true
set_manager| this.set = this.set_manager = function( | w, | | h, | | x, | | y | ) |
|
Template function sets the most common template properties for the element Aliasset() Parameters| int w | width (pixels) | | int h | height (pixels) | | int x | position on the x axis (pixels) | | int y | position on the y axis (pixels) |
See alsoVegUINode::set_node
unblock_key| this.unblock_key = function( | keyCode | ) |
|
Removes a keycode block set by <block_key> method Parameters| array keyCode | key codes to unblock |
See also<block_key> ExampleManager.unblock_key([37,38,39,40]);
VegUIBBoxBounding box for elements, limits where an element can be moved to. Every VegUIElement has a bounding box located at its BBox property Summary | | | | | | | | | checks if the element is within the boundin box’s border, if not the element will be moved to be within the bounding box’s border | | | | Validates the position of the element that the bounding box belongs to |
Object Properties| x | int, x position (pixels) | | y | int, y position (pixels) | | w | int, width (pixels) | | h | int, height (pixels) | | x2 | int, right position (pixels) | | y2 | int, bottom position (pixels) | | enabled | bool, true if bounding box is enabled | | c | bool, true if auto correct mode is enabled | | bumped | int, holds the direction where the last collision happened |
Auto correct modeif auto correct mode is on the element the bounding box is linked to will be moved back inside the bounding box should it happen to be located outside of the bounding box
VegUIBBox| function VegUIBBox( | VegUIElement | ) |
|
Constructor Parameters| VegUIElement Element | the vegui element this bounding box belongs to |
correct| this.correct = function() |
checks if the element is within the boundin box’s border, if not the element will be moved to be within the bounding box’s border
set| this.set = function( | x, | | y, | | w, | | h, | | b, | | c | ) |
|
sets the bounding box up Parameters| int x | position on the x coordinate (pixels) | | int y | position on the y coordinate (pixels) | | int w | width (pixels) | | int h | height (pixels) | | bool b | enable or disable the bounding box | | boolc c | enable or disable auto correct mode |
validate| this.validate = function( | x, | | y | ) |
|
Validates the position of the element that the bounding box belongs to Parameters| <int x> | x position to check, if ommited this.Parent.x() is used | | <int y> | y position to check, if ommited this.Parent.y() is used |
Returns| int | n if position of the element is invalid then the direction of the collision will be returned (Generic directions) | | int | 0 if position of the element is valid |
VegUIDynFuncAllows to have a function with dynamic content Summary | | | | | | | | | Adds a function to the stack | | Executes all the functions in the stack | | Free a unique function id effectivly removing the function linked to it from the stack |
Object Properties| Funcs | Array, holds the functions | | returnVal | variable, holds the value that will be returned by the execute method |
VegUIDynFunc| function VegUIDynFunc( | returnVal | ) |
|
Constructor Parameters| var returnVal | value to be returned by the execute method |
add| this.add = function( | fn, | | id | ) |
|
Adds a function to the stack Parameters| function fn | function to be added to the stack | | var id | unique id string |
Code examplemyDynFunc.add(function() { alert('hi'); }, 'hi');
See alsofree
execute| this.execute = function( | argArr | ) |
|
Executes all the functions in the stack Parameters| <Array ArgArr> | Array that can hold various parameters. In order for functions in the stack to be able to work with the argArr argument they need to be defined with it in mind |
Code examplemyDynFunc.add( function(argArr) { alert(argArr[0]); } ); myDynFunc.execute(['hello world']);
Returns| variable | returns the value of this.returnValue |
freeFree a unique function id effectivly removing the function linked to it from the stack Parameters| variable id | unique function id |
See alsoadd
|