Difference between revisions of "Lua:Class:Control"

From Cheat Engine
Jump to navigation Jump to search
Line 1: Line 1:
 
[[Category:Lua]]
 
[[Category:Lua]]
Control '''class''': ('''Inheritance''': ''[[Lua:Class:Component|Component]]''->''[[Lua:Class:Object|Object]]'')
+
'''Form Class''' (Inheritance ''[[Lua:Class:ScrollingWinControl|ScrollingWinControl]]''->''[[Lua:Class:CustomControl|CustomControl]]''->''[[Lua:Class:WinControl|WinControl]]''->''[[Lua:Class:Control|Control]]''->''[[Lua:Class:Component|Component]]''->''[[Lua:Class:Object|Object]]'')
 +
 
 +
  The Form class is a window
  
Base class for gui controls.
 
  
== Properties ==
+
'''createForm'''(visible OPT)
 +
  Creates a Form class object(window) and returns the pointer for it. Visible is default true but can be changed
  
; Caption : string
 
: The text of a control.
 
  
; Top : integer
+
'''createFormFromFile'''(filename)
: The x position.
+
  Creates a Form class object and initializes it based on the data in the given file.
 +
  It returns the generated form
  
; Left : integer
+
== Properties ==
: 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 ==
 
== Methods ==
 +
'''saveToFile'''(filename)
 +
  Saves a userdefined form. (DOES NOT WORK ON NORMAL FORMS LIKE MAINFORM)
  
; getLeft() : integer
+
'''centerScreen'''()
: Returns the left position.
+
  Places the form at the center of the screen
 
 
; 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
+
'''hide'''()
: gets the enabled state of the control.
+
  Hide the form
  
; setEnabled(''state'')
+
'''show'''()
: Sets the enabled state of the control.
+
  Show the form
  
; getVisible() : boolean
+
'''showModal'''()  
: gets the visible state of the control.
+
  Show the form and wait for it to close and get the close result
  
; setVisible(''state'')
+
'''isForegroundWindow'''()  
: sets the visible state of the control.
+
  returns true if the specified form has focus
  
; getColor() : integer
+
'''onClose'''(function)  
: gets the color.
+
  function (sender)  Return a CloseAction to determine how to close the window
  
; setColor(''rgb'')
+
'''getMenu'''(form)
: Sets the color.
+
  Returns the mainmenu object of this form
  
; getParent() : WinControl
+
'''setMenu'''(mainmenu)
: Returns nil or an object that inherits from the [[WinControl]] class.
+
  Sets a menu for the form
  
; setParent(''winControl'')
 
: Sets the parent for this control.
 
  
; getPopupMenu() : Menu
+
== Examples ==
: Returns the pop up menu.
+
<pre>
 +
function goodbyeMessage(sender)
 +
  print "called by form_onClose"
 +
  closeCE()                   -- Just closes ce
 +
end
  
; setPopupMenu()
+
local forms = createForm(true) -- true = visible(optional), false = not visible when created.
: Sets the pop up menu.
+
forms.hide()              -- hides the form
 +
sleep(3000)
 +
forms.show()                -- again makes the form visible
 +
sleep(3000)
 +
forms.centerScreen()      -- Places the form at the center of the screen
 +
if forms.isForegroundWindow(forms)  then
 +
  print "form in focus"
 +
end
 +
forms.onClose(goodbyeMessage)  -- delegates goodbyeMessage function. goodbyeMessage should have the prototype "goodbyeMessage(oneArgument)"
 +
</pre>
  
; 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}}
 
{{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]]
 

Revision as of 01:54, 25 January 2018

Form Class (Inheritance ScrollingWinControl->CustomControl->WinControl->Control->Component->Object)

 The Form class is a window


createForm(visible OPT)

 Creates a Form class object(window) and returns the pointer for it. Visible is default true but can be changed


createFormFromFile(filename)

 Creates a Form class object and initializes it based on the data in the given file.
 It returns the generated form

Properties

Methods

saveToFile(filename)

 Saves a userdefined form. (DOES NOT WORK ON NORMAL FORMS LIKE MAINFORM)

centerScreen()

 Places the form at the center of the screen

hide()

 Hide the form

show()

 Show the form

showModal()

 Show the form and wait for it to close and get the close result

isForegroundWindow()

 returns true if the specified form has focus

onClose(function)

 function (sender)  Return a CloseAction to determine how to close the window

getMenu(form)

 Returns the mainmenu object of this form

setMenu(mainmenu)

 Sets a menu for the form


Examples

function goodbyeMessage(sender)
  print "called by form_onClose"
  closeCE()                    -- Just closes ce
end

local forms = createForm(true) -- true = visible(optional), false = not visible when created.
forms.hide()               -- hides the form
sleep(3000)
forms.show()                -- again makes the form visible
sleep(3000)
forms.centerScreen()       -- Places the form at the center of the screen
if forms.isForegroundWindow(forms)  then
  print "form in focus"
end
forms.onClose(goodbyeMessage)   -- delegates goodbyeMessage function. goodbyeMessage should have the prototype "goodbyeMessage(oneArgument)"


See also