-
Notifications
You must be signed in to change notification settings - Fork 16
TextField Objects
#Overview TextField objects can only be created after you have a gui object, by calling the gui's addField method. They are the third and most interesting element yet, capable of a myriad of things. They're focusable, like buttons; you can type into them, changing what they say; you can select portions of their text, with shift+arrows or with the mouse; they support clipboard operations with the standard shortcuts, ctrl+c, ctrl+x, and ctrl+v. As components go, they are pretty bad-ass. I mean, they can't do anything you could imagine, like buttons can, but really, buttons can't do jack unless you write the function for them to do stuff, so they're not really that hot. TextFields, though! Wow!
- posX, posY, width, height
- The position and dimensions of the TextField, in screen coordinates.
- text
- The text contained in the TextField.
- style
- The style table to use on this gui. Style table can be loaded with gml.loadStyle(), by default an included default style will be used.
- gui
- the gui object this TextField is contained by.
- textfield:hide()
- Hides the TextFields, hiding it and preventing it from being drawn or interacted with.
- textfield:show()
- Unhides the TextFields, allowing it to be interacted with again.
- textfield:draw()
- Forces the TextField to be redrawn immediately. Useful if you've been directly manipulating it's style or properties from code and need those changes to update.
Handlers are properties that can be set to functions that will be called when certain events happen. Some handlers are common to all components, like onClick, while others are specific to certain types, like onScroll. However, some common handlers are implemented internally, and overriding them can cause undesired results. Only those events listed on these pages for a given element type should be assigned in your programs.
- onDoubleClick(textfield,mouseX,mouseY,textfield)
- Called when you double-click on the textfield.
Styles specific to TextFields are applied in gui style sheets using the element "textfield". Like Buttons, the only gss-recognized state that currently applies to TextFields is :focus.
The textfield will inherit the style table used by their containing gui, unless they are explicitly given their own style table. Individual style properties can also be set as values directly on the TextField object, ex, "textfield["selected-color"]=0x00ffff" would make the selected text bright cyan.
For more general information on styles, see the styles page
Propery | Value Type | Description |
---|---|---|
text-color | int1 | the color of the TextField's text |
text-background | int1 | the background color used for the TextField |
selected-color | int1 | the color of the TextField's selected text |
selected-background | int1 | the background color used for the TextField's selected text |
1colors are 24-bit, with 8 bits each R, G, and B, and can be given as normal integers, like 0 (which would be black), or hex values, like 0xff0000 (red).