Difference between revisions of "Lua:Class:Control"

From Cheat Engine
Jump to navigation Jump to search
(Undo revision 5662 by TheyCallMeTim13 (Talk))
 
(10 intermediate revisions by 2 users not shown)
Line 1: Line 1:
'''Control Class''': (Inheritance: [[Component]]->[[Object]])
+
[[Category:Lua]]
 +
Control '''class''': ('''Inheritance''': ''[[Lua:Class:Component|Component]]''->''[[Lua:Class:Object|Object]]'')
  
Base class for gui controls
+
Base class for gui controls.
  
===Properties===
+
== Properties ==
  Caption: string - The text of a control
 
  Top : integer - The x position
 
  Left : integer - The y position
 
  Width : integer - The width of the control
 
  Height : integer - The height of the control
 
  ClientWidth: integer - The usable width inside the control (minus the borders)
 
  ClientHeight: integer - The usable height the control (minus the borders)
 
  Align: AlignmentOption - Alignment of the control
 
  Enabled: boolean - Determines if the object is usable or greyed out
 
  Visible: boolean - Determines if the object is visible or not
 
  Color: ColorDefinition/RGBInteger - The color of the object. Does not affect the caption
 
  Parent: WinControl - The owner of this control
 
  PopupMenu: PopupMenu - The popup menu that shows when rightclicking the control
 
  Font: Font - The font class associated with the control
 
  OnClick: function - The function to call when a button is pressed
 
  
===Methods===
+
; Caption : string
  getLeft()
+
: The text of a control.
  setLeft(integer)
 
  getTop()
 
  setTop(integer)
 
  getWidth()
 
  setWidth(integer)
 
  getHeight()
 
  setHeight()
 
  setCaption(caption) : sets the text on a control. All the gui objects fall in this category
 
  getCaption() : Returns the text of the control
 
  setPosition(x,y): sets the x and y position of the object base don the top left position (relative to the client array of the owner object)
 
  getPosition(): returns the x and y position of the object (relative to the client array of the owner object)
 
  setSize(width,height) : Sets the width and height of the control
 
  getSize() : Gets the size of the control
 
  setAlign(alignmentoption): sets the alignment of the control
 
  getAlign(alignmentoption): gets the alignment of the control
 
  getEnabled() : gets the enabled state of the control
 
  setEnabled(boolean) : Sets the enabled state of the control
 
  getVisible() : gets the visible state of the control
 
  setVisible(boolean) : sets the visible state of the control
 
  getColor() : gets the color
 
  setColor(rgb) : Sets the color
 
  getParent() : Returns nil or an object that inherits from the Wincontrol class
 
  setParent(wincontrol) : Sets the parent for this control
 
  getPopupMenu()
 
  setPopupMenu()
 
  getFont():  Returns the Font object of this object
 
  setFont():  Assigns a new font object. (Not recommended to use. Change the font object that's already there if you wish to change fonts)
 
  repaint(): Invalidates the graphical area of the control and forces and update
 
  update() : Only updates the invalidated areas
 
  setOnClick(functionnameorstring) : Sets the onclick routine
 
  getOnClick(): Gets the onclick function
 
  doClick():  Executes the current function under onClick
 
  
 +
; Top : integer
 +
: The x position.
  
 +
; Left : integer
 +
: The y position.
  
 +
; Width : integer
 +
: The width of the control.
  
 +
; Height : integer
 +
: The height of the control.
  
<pre>
+
; ClientWidth &#58; integer
--Example:
+
: The usable width inside the control (minus the borders).
  
function clickroutine(sender) --  onClick()
+
; ClientHeight &#58; integer
print "editbox2 clicked"
+
: The usable height the control (minus the borders).
end
 
  
local forms = createForm()
+
; Align &#58; AlignmentOption
local labels = createLabel(forms)
+
: Alignment of the control.
  
--Caption
+
; Enabled &#58; boolean
labels.Caption="My first label"
+
: Determines if the object is usable or greyed out.
local variable = labels.Caption
 
print(variable)
 
  
--Position
+
; Visible &#58; boolean
labels.setPosition(30,30)
+
: Determines if the object is visible or not.
x,y=labels.getPosition()
 
print("X coord of label is "..x.."; Y coord of label is "..y)
 
  
--Enabled?
+
; Color &#58; ColorDefinition/RGBInteger
local editbox1 = createEdit(forms)
+
: The color of the object. Does not affect the caption.
local editbox2 = createEdit(forms)
 
editbox1.Enabled=false
 
if editbox1.Enabled then
 
  
  else
+
; Parent &#58; WinControl
  print "editbox1 not enabled"
+
: The owner of this control.
  editbox1.Caption="editbox1"
 
end
 
  
editbox2.Enabled=true
+
; PopupMenu &#58; PopupMenu
  if editbox2.Enabled then
+
: The popup menu that shows when rightclicking the control.
  print "editbox2  enabled"
 
  editbox2.Caption="editbox2"
 
end
 
  
editbox1.setPosition(30,60)
+
; Font &#58; Font
editbox2.setPosition(30,90)
+
: The font class associated with the control.
  
--Visibility
+
; OnClick &#58; function
local editbox3 = createEdit(forms)
+
: The function to call when a button is pressed.
editbox3.Visible=true  -- If false editbox3 would not be displayed on the form.
 
if editbox3.Visible then
 
  editbox3.Caption="editbox3"  -- Sets the caption only when visible
 
  editbox3.setPosition(editbox3,30,120)
 
end
 
  
--Color
+
== Methods ==
labels.Color=123456  -- color code in hex (range 000000 to FFFFFF)
 
local colorCode = labels.Color
 
print(colorCode)
 
  
--Onclick
+
; getLeft() &#58; integer
editbox2.OnClick=clickroutine -- clickroutine must have exactly one argument
+
: Returns the left position.
--alternatively: editbox2.OnClick="clickroutine"  --the function clickroutine will then be searched in _G when the click event triggers
 
  
 +
; setLeft(''value'')
 +
: Sets the left position.
  
 +
; getTop() &#58; integer
 +
: Returns the top position.
  
</pre>
+
; setTop(''value'')
 +
: Sets the top position.
 +
 
 +
; getWidth() &#58; integer
 +
: Returns the width.
 +
 
 +
; setWidth(''value'')
 +
: Sets the width.
 +
 
 +
; getHeight() &#58; integer
 +
: Returns the height.
 +
 
 +
; setHeight()
 +
: Sets the height.
 +
 
 +
; setCaption(''caption'')
 +
: Sets the text on a control. All the gui objects fall in this category.
 +
 
 +
; getCaption() &#58; string
 +
: Returns the text of the control
 +
 
 +
; setPosition(''x'', ''y'')
 +
: Sets the x and y position of the object base don the top left position (relative to the client array of the owner object)
 +
 
 +
; getPosition() &#58; (integer, integer)
 +
: Returns the x and y position of the object (relative to the client array of the owner object)
 +
 
 +
; setSize(''width'', ''height'')
 +
: Sets the width and height of the control
 +
 
 +
; getSize() &#58; (integer, integer)
 +
: Gets the size of the control
 +
 
 +
; setAlign(''alignmentOption'')
 +
: sets the alignment of the control.
 +
 
 +
; getAlign(''alignmentOption'')
 +
: gets the alignment of the control.
 +
 
 +
; getEnabled() &#58; boolean
 +
: gets the enabled state of the control.
 +
 
 +
; setEnabled(''state'')
 +
: Sets the enabled state of the control.
 +
 
 +
; getVisible() &#58; boolean
 +
: gets the visible state of the control.
 +
 
 +
; setVisible(''state'')
 +
: sets the visible state of the control.
 +
 
 +
; getColor() &#58; integer
 +
: gets the color.
 +
 
 +
; setColor(''rgb'')
 +
: Sets the color.
 +
 
 +
; getParent() &#58; WinControl
 +
: Returns nil or an object that inherits from the [[WinControl]] class.
 +
 
 +
; setParent(''winControl'')
 +
: Sets the parent for this control.
 +
 
 +
; getPopupMenu() &#58; Menu
 +
: Returns the pop up menu.
 +
 
 +
; setPopupMenu()
 +
: Sets the pop up menu.
 +
 
 +
; getFont() &#58; Font
 +
: Returns the Font object of this object.
 +
 
 +
; setFont()
 +
: Assigns a new font object. (Not recommended to use. Change the font object that's already there if you wish to change fonts).
 +
 
 +
; repaint()
 +
: Invalidates the graphical area of the control and forces and update.
 +
 
 +
; update()
 +
: Only updates the invalidated areas.
 +
 
 +
; setOnClick(''functionNameOrString'')
 +
: Sets the onclick routine.
 +
 
 +
; getOnClick() &#58; function
 +
: Gets the onclick function.
 +
 
 +
; doClick()
 +
: Executes the current function under onClick.
 +
 
 +
{{LuaSeeAlso}}
 +
 
 +
=== Related Functions ===
 +
* [[Lua:createClass|createClass]]
 +
* [[Lua:inheritsFromObject|inheritsFromObject]]
 +
* [[Lua:inheritsFromComponent|inheritsFromComponent]]
 +
* [[Lua:inheritsFromControl|inheritsFromControl]]
 +
* [[Lua:inheritsFromWinControl|inheritsFromWinControl]]
 +
 
 +
=== Related Classes ===
 +
* [[Lua:Class:Object|Object]]
 +
* [[Lua:Class:Control|Control]]
 +
* [[Lua:Class:WinControl|WinControl]]
 +
* [[Lua:Class:Application|Application]]
 +
* [[Lua:Class:Form|Form]]

Latest revision as of 01:55, 25 January 2018

Control class: (Inheritance: Component->Object)

Base class for gui controls.

Properties[edit]

Caption : string
The text of a control.
Top : integer
The x position.
Left : integer
The y position.
Width : integer
The width of the control.
Height : integer
The height of the control.
ClientWidth : integer
The usable width inside the control (minus the borders).
ClientHeight : integer
The usable height the control (minus the borders).
Align : AlignmentOption
Alignment of the control.
Enabled : boolean
Determines if the object is usable or greyed out.
Visible : boolean
Determines if the object is visible or not.
Color : ColorDefinition/RGBInteger
The color of the object. Does not affect the caption.
Parent : WinControl
The owner of this control.
PopupMenu : PopupMenu
The popup menu that shows when rightclicking the control.
Font : Font
The font class associated with the control.
OnClick : function
The function to call when a button is pressed.

Methods[edit]

getLeft() : integer
Returns the left position.
setLeft(value)
Sets the left position.
getTop() : integer
Returns the top position.
setTop(value)
Sets the top position.
getWidth() : integer
Returns the width.
setWidth(value)
Sets the width.
getHeight() : integer
Returns the height.
setHeight()
Sets the height.
setCaption(caption)
Sets the text on a control. All the gui objects fall in this category.
getCaption() : string
Returns the text of the control
setPosition(x, y)
Sets the x and y position of the object base don the top left position (relative to the client array of the owner object)
getPosition() : (integer, integer)
Returns the x and y position of the object (relative to the client array of the owner object)
setSize(width, height)
Sets the width and height of the control
getSize() : (integer, integer)
Gets the size of the control
setAlign(alignmentOption)
sets the alignment of the control.
getAlign(alignmentOption)
gets the alignment of the control.
getEnabled() : boolean
gets the enabled state of the control.
setEnabled(state)
Sets the enabled state of the control.
getVisible() : boolean
gets the visible state of the control.
setVisible(state)
sets the visible state of the control.
getColor() : integer
gets the color.
setColor(rgb)
Sets the color.
getParent() : WinControl
Returns nil or an object that inherits from the WinControl class.
setParent(winControl)
Sets the parent for this control.
getPopupMenu() : Menu
Returns the pop up menu.
setPopupMenu()
Sets the pop up menu.
getFont() : Font
Returns the Font object of this object.
setFont()
Assigns a new font object. (Not recommended to use. Change the font object that's already there if you wish to change fonts).
repaint()
Invalidates the graphical area of the control and forces and update.
update()
Only updates the invalidated areas.
setOnClick(functionNameOrString)
Sets the onclick routine.
getOnClick() : function
Gets the onclick function.
doClick()
Executes the current function under onClick.

See also[edit]

Related Functions[edit]

Related Classes[edit]