World of Hello
Public Member Functions | List of all members
CreateButton Class Reference

a button element. More...

Inheritance diagram for CreateButton:
element event

Public Member Functions

 CreateButton (string text, int x=0, int y=0, int w=80, int h=37)
 create a button. More...
 
element setImage (string img)
 sets the image. More...
 
string getImage ()
 gets the image. More...
 
element setImageAsGUISprite (bool imageAsGUISprite=true)
 sets the image as a resizable GUI image sprite. More...
 
element crop (int x, int y, int w, int h)
 crops the button image to a part of the image. More...
 
multiReturn< int, int, int, int > getCrop ()
 get the button rectangle crop of the image. More...
 
element copyImageTo (string imagePath, int toX=0, int toY=0, int fromX=0, int fromY=0, int fromW=-1, int fromH=-1, int layer=0, string storeAs=getImage(), int totalW=-1, int totalH=-1)
 copy part of an image to this texture. More...
 
element setDrawBorder (bool draw=true)
 sets whether the border is drawn or not. More...
 
element setScaleImage (bool scaleImage=true)
 sets whether the button image itself should scale. More...
 
element setText (string text)
 sets the button text. More...
 
string getText ()
 gets the button text. More...
 
element setPressed (bool pressed=true)
 sets whether the button is pressed. More...
 
bool isPressed ()
 checks if the button was pressed. More...
 
element setAlphaChannel (bool alphaChannel=true)
 sets the use of alpha channel or not. More...
 
element setDirectionalButton (bool directional=true, string dir="left")
 sets the button as a directional button. More...
 
- Public Member Functions inherited from element
conditional< string, bool > runScript ()
 run the element's script once. More...
 
element setRunScript (bool runScript=true)
 runs the script each frame. More...
 
element setScript (string code)
 set the element's script. More...
 
string getScript ()
 get the current code of the element. More...
 
conditional< string, bool > doScriptString (string code)
 does a script string. More...
 
element blockFunction (string functionName, bool block=true)
 blocks a function from being used outside of the current script. More...
 
string getID ()
 get the ID of the element. More...
 
bool setID (string ID)
 set the ID of the element. More...
 
float getX ()
 get the X axis of the element. More...
 
float getY ()
 get the Y axis of the element. More...
 
float getWidth ()
 get the width of the element. More...
 
float getHeight ()
 get the height of the element. More...
 
element bringToFront ()
 brings the element to the top-most layer. More...
 
element bringToBack ()
 brings the element to the bottom-most layer. More...
 
element setX (float X)
 sets the X axis of the element More...
 
element setY (float Y)
 sets the Y axis of the element. More...
 
element setWidth (float width)
 sets the width of the element. More...
 
element setWidth (float height)
 sets the height of the element. More...
 
element setScale (float scale)
 sets the scale of the element. More...
 
element setScale (float widthScale, float heightScale)
 sets the width and height scale of the element. More...
 
element setMaintainAspectRatio (bool maintainAspectRatio=true)
 sets whether or not changing the width/height maintains aspect ratio scaling. More...
 
element center ()
 centers the element. More...
 
element setScalePosition ()
 sets that setScale() should also scale the element's position. More...
 
element setScalePosition (bool scalePosition)
 sets whether or not setScale() should also scale the element's position. More...
 
element setScalePosition (bool scaleX, bool scaleY)
 sets whether or not setScale() should also scale the element's X and Y position. More...
 
element setCollisionWith (element elem)
 add collision with another element. More...
 
element removeCollisionWith (element elem)
 removes the collision with another element. More...
 
element setMinWidth (float minWidth)
 sets the minimum resize width. More...
 
element setMinHeight (float minHeight)
 sets the minimum resize height. More...
 
element setMaxWidth (float maxWidth)
 sets the maximum resize width. More...
 
element setMaxHeight (float maxHeight)
 sets the maximum resize height. More...
 
string getType ()
 get the type of this element. More...
 
element setPosition (float X, float Y)
 set the position of the element. More...
 
multiReturn< float, float > getPosition ()
 gets the position of the element. More...
 
element setTabEnabled (bool enabled=true)
 sets whether or not you can tab to get to this element. More...
 
element setTabOrder (int orderNo)
 sets the order in which this element can be tabbed to. More...
 
element setClipped (bool clipped)
 sets whether the element should be cut off by it's rectangle. More...
 
element setDPIAware (bool dpiAware=true)
 
element setDefaultControls (bool defaultControls, float speed)
 sets whether the element can be moves with keys. More...
 
element setFocused (bool focused=true)
 set the focus of the element. More...
 
bool isFocused ()
 get whether or not the element is in focus. More...
 
element setMovable (bool movable=true, int movableHeight=-1)
 sets the movability of the element. More...
 
element setMovableBoundaries (int x, int y, int endX, int endY)
 sets the movable boundaries. More...
 
multiReturn< int, int, int, int > getMovableBoundaries ()
 gets the movable boundaries. More...
 
bool hitsBoundary (string direction)
 checks if the element has collided with a boundary. More...
 
element setResizable (bool resizable=true)
 sets whether the element is resizable. More...
 
element setResizableDepth (int resizableDepth)
 sets the depth of the pixels the user must click to resize an element. More...
 
element setRect (int x, int y, int width, int height)
 sets the rectangle of the element. More...
 
element hide ()
 sets the element to be invisible. More...
 
element show ()
 sets the element to be visible. More...
 
element setVisible (bool visible=true)
 sets the visibility of the element. More...
 
bool isVisible ()
 get the visibility of the element. More...
 
element addElement (element elem)
 adds a child element. More...
 
element setParent (element elem)
 adds this element as a child of the given element. More...
 
element removeElement (element elem)
 removes a child element. More...
 
element[] getElements ()
 gets all child elements. More...
 
element getParent ()
 get the parent element. More...
 
element resetLayers ()
 resets the order of the layers. More...
 
void remove ()
 removes the element. More...
 
string getObject (bool includeChildren=true)
 get the element as a total object. More...
 
element doCommands (string cmd)
 creates the element from an object like a server command. More...
 
element removeFromClients ()
 removes the element from all online clients. More...
 
element sendToClients (bool removeOthers=false, string key="", string keyAns="")
 sends the element to all connected clients who meet the criteria. More...
 
element setProperty (string property, string value)
 sets a property of the element to be sent next. More...
 
string getProperty (string property)
 gets the value of a set property. More...
 
string[] getProperties ()
 gets all properties from the object. More...
 
element removeProperty (string property)
 removes a property from the object. More...
 
element clearProperties ()
 removes all properties from the object. See removeProperty() More...
 
bool setParentScript (string scriptPath)
 sets the parent script. More...
 
- Public Member Functions inherited from event
void setEventListener (ElementEvent event, function func,...)
 sets a function to run on the given event. Removes all other event listeners of the same event type. More...
 
void addEventListener (ElementEvent event, function func,...)
 adds a function to run on the given event. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from element
static void drawRectangle (int x, int y, int width=100, int height=50, bool border=false, int r=0, int g=0, int b=0, int a=255, clipX=0, clipY=0, clipWidth=game:getWindowWidth(), clipHeight=game:getWindowHeight())
 draws a 2D rectangle on top of the element. More...
 

Detailed Description

a button element.

Constructor & Destructor Documentation

◆ CreateButton()

CreateButton::CreateButton ( string  text,
int  x = 0,
int  y = 0,
int  w = 80,
int  h = 37 
)

create a button.

   Creates a button that can be pressed.\n
   Derives all element functions.
Parameters
Thetext the button should display on it.
(optional)The X axis the button should be placed on the screen.
(optional)The Y axis the button should be placed on the screen.
(optional)The width of the button.
(optional)The height of the button.

Member Function Documentation

◆ copyImageTo()

element CreateButton::copyImageTo ( string  imagePath,
int  toX = 0,
int  toY = 0,
int  fromX = 0,
int  fromY = 0,
int  fromW = -1,
int  fromH = -1,
int  layer = 0,
string  storeAs = getImage(),
int  totalW = -1,
int  totalH = -1 
)

copy part of an image to this texture.

   Copies part, or the whole, image to this element's texture.\n
   If this element does not have a texture, one will be created; see totalW and totalH for determining the size of the texture created.\n
   The new texture can also be stored into the driver and later set by another element; see storeAs.
Parameters
Theimage file to copy onto this element's texture.
(optional)The X axis of the texture to place the image at.
(optional)The Y axis of the texture to place the image at.
(optional)The X source of the image to start copying to the element's texture.
(optional)The Y source of the image to start copying to the element's texture.
(optional)The width of the image to copy to the element's texture. If negative, it is the whole image's width.
(optional)The height of the image to copy to the element's texture. If negative, it is the whole image's height.
(optional)The layer of the element's texture to copy to. If the layer doesn't exist, one will be created.
(optional)The name of the new texture to be stored in the driver.
(optional)The total width of the new texture. If negative and a texture has been set, then uses the texture's width. If negative and no texture set, then uses the element's X scale.
(optional)The total height of the new texture. If negative and a texture has been set, then uses the texture's height. If negative and no texture set, then uses the element's Y scale.
Returns
Returns itself.

◆ crop()

element CreateButton::crop ( int  x,
int  y,
int  w,
int  h 
)

crops the button image to a part of the image.

   Crops the source rectangle of the image to a part of the image.
Parameters
Thesource X axis of the image.
Thesource Y axis of the image.
Thesource width of the image.
Thesource height of the image.
Returns
Returns itself.

◆ getCrop()

multiReturn<int, int, int, int> CreateButton::getCrop ( )

get the button rectangle crop of the image.

   Gets the source rectangle of the cropped image.\n
Returns
(1) The image source X. (2) The image source Y.
(3) The image source width. (4) The image source height.

◆ getImage()

string CreateButton::getImage ( )

gets the image.

Returns
The set image.

◆ getText()

string CreateButton::getText ( )

gets the button text.

Returns
The text of the button.

◆ isPressed()

bool CreateButton::isPressed ( )

checks if the button was pressed.

   WARNING: DEPRECATED. Please use "function onButtonPressed(button)" instead.\n
   Reason being that CreateButton:isPressed() checks every frame, while "onButtonPressed()" triggers on event.
Returns
Whether or not the button was pressed.

◆ setAlphaChannel()

element CreateButton::setAlphaChannel ( bool  alphaChannel = true)

sets the use of alpha channel or not.

   If the alpha channel is set to true, the image becomes transparent based on the pixels.
   I.E black pixels become invisible.
Parameters
(optional)Whether or not the alpha channel should be used.
Returns
Returns itself.

◆ setDirectionalButton()

element CreateButton::setDirectionalButton ( bool  directional = true,
string  dir = "left" 
)

sets the button as a directional button.

   Sets whether or not the button is a directional button.\n
   Use this function to display left/right/up/down buttons, similar to
   the ones used in scrollbars.
Parameters
(optional)Whether or not the button is a directional button.
(optional)The direction of the button as a string ("left", "right", "up", "down").
Returns
Returns itself.

◆ setDrawBorder()

element CreateButton::setDrawBorder ( bool  draw = true)

sets whether the border is drawn or not.

Parameters
(optional)Whether the border is drawn or not.
Returns
Returns itself.

◆ setImage()

element CreateButton::setImage ( string  img)

sets the image.

   Set the button image to a new image.\n
   If the image file does not exist,
   gets it from the server if it exists on the server. If the file
   is out of date from the server's file, it will be replaced.
   If the server file and the local file does not exist, the image does not change.\n
Parameters
Theserver image file path.
Returns
Returns itself.

◆ setImageAsGUISprite()

element CreateButton::setImageAsGUISprite ( bool  imageAsGUISprite = true)

sets the image as a resizable GUI image sprite.

   Sets the image to allow resizing without losing quality, used for GUIs.\n
   The GUI sprite forms a 3x3 grid on the element's image and uses the corners of the image for the element, and the edges of the image for the element's edges.
Parameters
(optional)Whether or not the image is displayed as a GUI sprite.
Returns
Returns itself.

◆ setPressed()

element CreateButton::setPressed ( bool  pressed = true)

sets whether the button is pressed.

Parameters
(optional)Whether the button is pressed or not.
Returns
Returns itself.

◆ setScaleImage()

element CreateButton::setScaleImage ( bool  scaleImage = true)

sets whether the button image itself should scale.

   True by default, sets whether the button image should scale to the element's width and height or not.
Parameters
(optional)Whether or not the button image should scale.
Returns
Returns itself.

◆ setText()

element CreateButton::setText ( string  text)

sets the button text.

Parameters
Thenew text of the button.
Returns
Returns itself.