Skip to content

Class Controls

Kristian Virtanen edited this page Oct 28, 2024 · 4 revisions

Description:

The Controls class provides functionality for creating and managing UI elements (such as buttons and textboxes) within the GraphicsWindow. It allows you to add, move, resize, and remove these controls, as well as track user interactions such as button clicks or text input.

It also manages error handling through the LastError property, which stores the most recent error message in case of a failed operation.

Properties

Controls.LastClickedButton

  • Description: Returns the name of the last clicked button, or null if no button has been clicked.
  • Example: "Button1"
  • Differences from orig. SB: none.

Controls.LastError

  • Description: Stores the last error message, if any operation fails, including a timestamp in yyyy-MM-dd HH:mm:ss format.
  • Example: "2024-10-16 14:30:00: Graphics window is not initialized."
  • Differences from orig. SB: Not available at original SB.

Controls.LastTypedTextBox

  • Description: Returns the name of the last text box that had text typed into it, or null if no text was typed.
  • Example: "TextBox1"
  • Differences from orig. SB: none.

Methods

Controls.AddButton(caption, left, top)

  • Description: Adds a button to the GraphicsWindow at the specified position (left, top) and returns the name of the button.
  • Parameters:
    • caption: The text displayed on the button.
    • left: The horizontal position of the button.
    • top: The vertical position of the button.
  • Returns: The name of the button (e.g., "Button1"), or null if an error occurred.
  • Example: Controls.AddButton("Submit", 100, 200)
  • Differences from orig. SB: none.

Controls.AddTextBox(left, top)

  • Description: Adds a single-line text box to the GraphicsWindow at the specified position (left, top) and returns the name of the text box.
  • Parameters:
    • left: The horizontal position of the text box.
    • top: The vertical position of the text box.
  • Returns: The name of the text box (e.g., "TextBox1"), or null if an error occurred.
  • Example: Controls.AddTextBox(100, 200)
  • Differences from orig. SB: none.

Controls.AddMultiLineTextBox(left, top)

  • Description: Adds a multi-line text box to the GraphicsWindow at the specified position (left, top) with default size, and returns the name of the text box.
  • Parameters:
    • left: The horizontal position of the text box.
    • top: The vertical position of the text box.
  • Returns: The name of the text box (e.g., "MultiLineTextBox1"), or null if an error occurred.
  • Example: Controls.AddMultiLineTextBox(100, 200)
  • Differences from orig. SB: none.

Controls.AddMultiLineTextBoxWithSize(left, top, width, height)

  • Description: Adds a multi-line text box to the GraphicsWindow at the specified position with a custom size, and returns the name of the text box.
  • Parameters:
    • left: The horizontal position of the text box.
    • top: The vertical position of the text box.
    • width: The width of the text box.
    • height: The height of the text box.
  • Returns: The name of the text box, or null if an error occurred.
  • Example: Controls.AddMultiLineTextBoxWithSize(100, 200, 300, 150)
  • Differences from orig. SB: Not available at original SB.

Controls.GetTextBoxText(textBoxName)

  • Description: Returns the text from the specified text box.
  • Parameters:
    • textBoxName: The name of the text box to retrieve text from.
  • Returns: The text in the text box, or null if the text box was not found.
  • Example: Controls.GetTextBoxText("TextBox1")
  • Differences from orig. SB: none.

Controls.SetTextBoxText(textBoxName, text)

  • Description: Sets the text in the specified text box.
  • Parameters:
    • textBoxName: The name of the text box.
    • text: The text to set in the text box.
  • Returns: true if successful, false if the text box was not found or an error occurred.
  • Example: Controls.SetTextBoxText("TextBox1", "Hello World!")
  • Differences from orig. SB: none.

Controls.Move(controlName, x, y)

  • Description: Moves the specified control to the given coordinates (x, y).
  • Parameters:
    • controlName: The name of the control to move.
    • x: The new horizontal position.
    • y: The new vertical position.
  • Returns: true if the control was successfully moved, false if the control was not found or an error occurred.
  • Example: Controls.Move("Button1", 150, 250)
  • Differences from orig. SB: none.

Controls.SetSize(controlName, width, height)

  • Description: Sets the size of the specified control.
  • Parameters:
    • controlName: The name of the control.
    • width: The new width of the control.
    • height: The new height of the control.
  • Returns: true if the control size was successfully set, false if the control was not found or an error occurred.
  • Example: Controls.SetSize("Button1", 100, 50)
  • Differences from orig. SB: none.

Controls.RemoveControl(controlName)

  • Description: Removes the specified control from the GraphicsWindow.
  • Parameters:
    • controlName: The name of the control to remove.
  • Returns: true if the control was successfully removed, false if the control was not found or an error occurred.
  • Example: Controls.RemoveControl("Button1")
  • Differences from orig. SB: none.

Top