LavishGUI:lguielement (Data Type)
Jump to navigation
Jump to search
Description
This data type provides and controls data for LGUI elements.
Members
- string Name: Name of the element
- int ID: Unique ID number of the element
- int X: X position relative to its parent
- int Y: Y position relative to its parent
- int AbsoluteX: X position relative to the display
- int AbsoluteY: Y position relative to the display
- int Width: Width of the element
- int Height: Height of the element
- bool Visible: True if the element is visible
- bool AlwaysOnTop: True if the element is "always on top"
- bool MouseOver: True if the element has mouse focus
- bool Focus: True of the element has keyboard focus
- string Type: Element type (such as "button")
- ... Parent: Parent element
- ... Children: First child element (bottom of Z order)
- ... Next: Next element
- ... Previous: Previous element
- ... FindChild[name]: Finds a direct child of this element with the given name
- ... FindUsableChild[name,type]: Finds a descendant of this element with the given name and element type
- bool LeftClickThru: Status of left click thru
- bool RightClickThru: Status of right click thru
- float Alpha: The alpha level set for the element
- float AbsoluteAlpha: The current alpha level
- float FadeAlpha: The alpha level set for fade alpha
- uint FadeDelay: Fade delay in milliseconds
- uint FadeDuration: Fade duration in milliseconds
- string FadeState: Will return what state fading is in (NORMAL DELAYING FADING FADED)
Methods
- AddChild[type,name,XML] : Adds a child of <type> with <name>. <XML> needs to be the full XML information.
- LeftClick : left clicks on the element
- LeftMouseDown : holds left mouse button down on the element
- LeftMouseUp : releases left mouse button
- RightClick : right clicks on the element
- RightMouseDown : holds right mouse button down on the element
- RightMouseUp : releases right mouse button
- SetX[#] : sets the elements X to #
- SetY[#] : sets the elements Y to #
- SetWidth[#] : sets the elements width to #
- SetHeight[#] : sets the elements height to #
- SetFocus : sets the keyboard focus to this element (if it can accept it)
- SetZOrder[how]: choices are alwaysontop, notalwaysontop, moveup, movedown, movetop, movebottom
- Show : forces the element visible
- Hide : forces the element invisible
- ToggleVisible : toggles visibility
- Destroy: Destroys the element
- SetLeftClickThru[bool]: Sets left click thru to TRUE or FALSE
- SetRightClickThru[bool]: Sets rigt click thru to TRUE or FALSE
- SetAlpha[#]: Sets the alpha to #
- SetFadeAlpha[#]: Sets the fade alpha to #
- Note on alphas. Element alpha is given as a floating point value, with 0 being transparent and 1 being opaque. Each element will be this number times as opaque as its parent. This means that an element with 0.5 can have a child with an alpha level of 2.0, and the resulting alpha level of the child will be 1.0 (e.g. 0.5*2.0=1.0). This value is carried to all descendants during rendering, so if that same child with the value of 2.0 but calculated alpha of 1.0 had its own child with a value of 0.5, the math would be 1.0*0.5=0.5. Note that any value over 1 is going to appear the same as 1 (they do not get any more opaque). Additionally, a fade effect is available for all elements as well, with automatic fading based on mouse position
- SetFadeDelay[#]: Sets the fade delay to # in milliseconds(1000 is 1 second). There must be a fade delay for fading to work.
- SetFadeDuration[value]: Sets the fade duration to # in milliseconds (1000 is 1 second).
- BeginFade: Begins fading
- ResetFade: Resets alpha to normal
- InstantFade: Fades instantly
Returns
Same as Name
Examples
Add a Child
- UIElement[${TestXML}]:AddChild[text,test,<Text name='test'><X>15</X><Y>20</Y><Width>100</Width><Height>100</Height><Text>Hello World</Text></Text>]
Get the ID of an element
- echo Element #: ${UIElement[main hud].ID}
- Output
Element #: 2
Toggle an elements visibility
UIElement[main hud].FindChild[fps]:ToggleVisibile
- This command toggles fps element on and off
Display an elements width and height
- echo Width: ${UIElement[main hud].FindChild[fps].Width} Height: ${UIElement[main hud].FindChild[fps].Height}
- Output
Width: 20 Height: 12
Display an elements type
- echo Type: ${UIElement[main hud].FindChild[fps].Type}
- Output
Type: hudelement
See if an element is visible
- echo Visible? ${UIElement[main hud].FindChild[fps].Visible}
- Output
Visible? TRUE
Left click an element
- UIElement[Button Window].FindChild[Exit button]:LeftClick
- This command left clicks on the "Exit button" child of "Button Window" window
Move an element to 100,150 location
- UIElement[main hud].FindChild[fps]:SetX[100]
- UIElement[main hud].FindChild[fps]:SetY[150]
- These commands will move the FPS element to 100,150
Set an element to always on top
- UIElement[main hud].FindChild[fps]:SetZOrder[alwaysontop]
- This command sets element "fps" in "main hud" to AlwaysOnTop