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

a list box element. More...

Inheritance diagram for CreateListBox:
element event

Public Member Functions

 CreateListBox (int x=0, int y=0, int w=100, int h=200)
 create a list box. More...
 
element setItemColor (int ind, int r, int g, int b, int a=255)
 set the color of an item. More...
 
conditional< nil, multiReturn< int, int, int,int > > getItemColor (int ind)
 get the color of an item. More...
 
element setSelected (conditional< int, string, bool > val,...)
 sets the selected item(s) by index or name. More...
 
conditional< int, int[]> getSelected ()
 gets the selected item(s) by index. More...
 
conditional< string, string[]> getSelectedName ()
 gets the selected item(s') text. More...
 
element setMultiSelect (bool multiSelect=true)
 sets whether the listbox is a multiselect box or not. More...
 
bool isMultiSelect ()
 gets whether the listbox is a multiselect box or not. More...
 
element addItem (string item, int pos=-1)
 adds an item to the list. More...
 
int getItem (string item, bool caseSensitive=true)
 gets the index of the first occurrence of an item. More...
 
string getItem (int ind)
 gets an item by index. More...
 
element removeItem (int ind)
 removes an item by index. More...
 
int getItemCount ()
 gets the amount of items in the list. More...
 
element clear ()
 clears all items from the list. 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 list box element.

Constructor & Destructor Documentation

◆ CreateListBox()

CreateListBox::CreateListBox ( int  x = 0,
int  y = 0,
int  w = 100,
int  h = 200 
)

create a list box.

   Creates a list box that can hold items.\n
   Once there are enough items that go over the height of the list box, a scroll bar will automatically be created on the list box.\n
   Derives all element functions.
Parameters
(optional)The X axis the box should be placed on the screen.
(optional)The Y axis the box should be placed on the screen.
(optional)The width of the box.
(optional)The height of the box.

Member Function Documentation

◆ addItem()

element CreateListBox::addItem ( string  item,
int  pos = -1 
)

adds an item to the list.

Parameters
Theitem to be added.
(optional)The position to add the item to. If not given, adds to end of list.
Returns
Returns itself.

◆ clear()

element CreateListBox::clear ( )

clears all items from the list.

Returns
Returns itself.

◆ getItem() [1/2]

string CreateListBox::getItem ( int  ind)

gets an item by index.

   Gets an item by it's index. Indexing starts at 0.
Parameters
Theindex (starting at 0) to get the item at.
Returns
The item of the given index.

◆ getItem() [2/2]

int CreateListBox::getItem ( string  item,
bool  caseSensitive = true 
)

gets the index of the first occurrence of an item.

   Gets an item's index by it's value. Indexing starts at 0.
Parameters
Theitem to get the index of.
(optional)Whether or not the search for the item is case sensitive.
Returns
The index of the first occurrence of the item.

◆ getItemColor()

conditional<nil, multiReturn<int, int, int ,int> > CreateListBox::getItemColor ( int  ind)

get the color of an item.

   Gets the color of an item added to the listbox by index.
   Item indexing starts at 0.
Parameters
Theindex of the item to get the color of.
Returns
(1) If the item exists in the listbox, then the amount of red, green, blue, and alpha. (2) Otherwise, nil.

◆ getItemCount()

int CreateListBox::getItemCount ( )

gets the amount of items in the list.

Returns
The amount of items in the list.

◆ getSelected()

conditional<int, int[]> CreateListBox::getSelected ( )

gets the selected item(s) by index.

   Gets the index of the item that is selected.\n
   Indexing starts at 1.\n
  Returns a single value if the listbox is a multiselect box, otherwise returns multiple values. If nothing selected, returns -1.
Returns
The index of the item that is selected. If no items are selected, then -1.

◆ getSelectedName()

conditional<string, string[]> CreateListBox::getSelectedName ( )

gets the selected item(s') text.

   Gets the name of the item that is selected.\n
  Returns a single value if the listbox is a multiselect box, otherwise returns multiple values. If nothing selected, returns nil.
Returns
The name of the item that is selected.

◆ isMultiSelect()

bool CreateListBox::isMultiSelect ( )

gets whether the listbox is a multiselect box or not.

Returns
If the listbox is a multiselect box, returns true. Otherwise, returns false.

◆ removeItem()

element CreateListBox::removeItem ( int  ind)

removes an item by index.

   Removes an item by it's index. Indexing starts at 0.
Parameters
Theitem index to be removed.
Returns
Returns itself.

◆ setItemColor()

element CreateListBox::setItemColor ( int  ind,
int  r,
int  g,
int  b,
int  a = 255 
)

set the color of an item.

   Sets the color of an item added to the listbox by index.
   Item indexing starts at 0.
Parameters
Theindex of the item to set the color.
Theamount of red (0-255).
Theamount of green (0-255).
Theamount of blue (0-255).
(optional)The amount of alpha (transparency) (0-255).
Returns
Returns itself.

◆ setMultiSelect()

element CreateListBox::setMultiSelect ( bool  multiSelect = true)

sets whether the listbox is a multiselect box or not.

  Sets if the listbox should allow selecting multiple items or not.
Parameters
(optional)whether or not the listbox is a multiselect box.
Returns
Returns itself.

◆ setSelected()

element CreateListBox::setSelected ( conditional< int, string, bool >  val,
  ... 
)

sets the selected item(s) by index or name.

   Sets the selected item by index or name.\n
   Indexing starts at 0.\n
  You may pass in any number of int or string arguments to select. If you pass in a boolean, that will be used to check case-sensitivity for strings passed. Sensitivity is TRUE by default.
  If you pass multiple boolean values, case-sensitivity will switch between names passed. For example:\n
  setSelected(0, 1, "test", true, "TEST2", false, "test2", true, "test3")\n
  This will select the first and second items in the list, then find "test" (case-sensitive) and select it, then find "TEST2" (case-sensitive), then find "test2" (not case-sensitive), then find "test3" (case-sensitive).\n
  If a string matches multiple items, only the first is selected; pass in the same string a second time to select the next item with the same name and so on...\n
  If multiple items are selected, the listbox will be set to a multiselect box.
Parameters
Theindex (if an int is passed) or name (if string passed) of the item to be selected. If boolean passed, used for case-sensitivity of the next strings passed.
(optional)Any number of any combinations of the val argument.
Returns
Returns itself.