Saltar al contenido principal

UI Objects (User Interface)

These objects allow you to create and customize 2D User Interface elements programmatically on the screen or inside a CustomWindow.

PanelValue Object

Used to display numeric or text values on the screen.

Tip

The screen is divided into a grid of 10 columns and 12 rows for standard panel positioning.

void PanelConfig(string desc, string v)

  • Description: Sets the panel description and value.

void PanelDescription(string t)

  • Description: Sets the panel description.

void Value(string/int/float/double/Vector3 value)

  • Description: Sets the value to display.

void SetPosition(int column, int row)

  • Description: Sets the panel position on the screen using the 10x12 grid.

void SetPosition(int col, int row, int length)

  • Description: Sets the panel position and its length (1 to 10 columns).

void SetPosition(float x, float y)

  • Description: Sets the panel position in a CustomWindow component (using pixels).

void SetSize(float x, float y)

  • Description: Sets the component size in a CustomWindow component.

void BackColor(Color col)

  • Description: Sets the panel background color.

void TextColor(Color col)

  • Description: Sets the panel description text color.

void ValueColor(Color col)

  • Description: Sets the panel value text color.

void Visible(bool value)

  • Description: Sets the panel visibility.

PanelButton Object

Used to create interactive buttons.

void ButtonText(string text)

  • Description: Sets the button text.

void SetPosition(int column, int row)

  • Description: Sets the button position on the screen (10 columns, 24 rows).

void SetPosition(int col, int row, int length)

  • Description: Sets the button position and its length.

void SetPosition(float x, float y)

  • Description: Sets the panel position in a CustomWindow.

void SetSize(float x, float y)

  • Description: Sets the component size in a CustomWindow.

void BackColor(Color col)

  • Description: Sets the button background color.

void TextColor(Color col)

  • Description: Sets the button text color.

void Visible(bool value)

  • Description: Sets the button visibility.

bool ButtonPresed

  • Description: Returns true if the button remains pressed.

Click Event

This event is activated when the user presses the button.

Example:

PanelButton but1;

public void Init()
{
but1 = MS.PanelButton("START");
but1.SetPosition(5, 12);
but1.ClickEvent += but1_ClickEvent;
}

public void Finish()
{
but1.ClickEvent -= but1_ClickEvent;
}

void but1_ClickEvent()
{
MS.Message("Activated");
}

InputValue Object

Used to create an input field where users can type data.

void PanelConfig(string desc, string v)

  • Description: Sets the panel description and text value.

void Value(string/int/float/double/Vector3 value)

  • Description: Sets the value to display in the text area.

string InputText() / int InputTextInt() / float InputTextFloat()

  • Description: Returns the typed text converted to the specified type.

Input Events

  • event StringChanged: Fires when the user ends the input value edit for a string.
  • event IntChanged: Fires when the user ends the input value edit for an integer.
  • event FloatChanged: Fires when the user ends the input value edit for a float.

Example:

InputValue input1;       

public void Init()
{
input1 = MS.InputDisplay("ENTER DATA");
input1.SetPosition(1, 1);
input1.Value(1);
input1.FloatChanged += Input1_FloatChanged;
}

public void Finish()
{
input1.FloatChanged -= Input1_FloatChanged;
}

void Input1_FloatChanged(float value)
{
if(value <= 0 || value > 10)
{
input1.Value(1);
}
}

TextBoxArea Object

Used to display multi-line text information.

string Text

  • Description: Sets/Gets the text inside the area.

void TextSize(float size)

  • Description: Sets the text size.

void BackgroundVisible(bool v)

  • Description: Sets the TextBox area background visible or invisible.

PanelSlider Object

Used to create a sliding bar to select numeric values.

void SliderConfig(string description, float min, float max, float def, int anInp)

  • Description: Configures the slider. If anInp > -1, the value is assigned to an analog PLC input.

void WholeNumbers(bool v)

  • Description: Sets if the slider will return integers (true) or decimals (false).

LabelUI Object

Used to display text labels on the screen or inside a window.

bool Autosize

  • Description: If true, the text size is adjusted automatically to the label size.

ImageArea Object

Used to display an image loaded from a local path.

void LoadImage(string path)

  • Description: Loads the image file from the indicated path.

void Transparency(float alpha)

  • Description: Sets the image transparency level (0.0 to 1.0).

CustomWindow Object

Used to create floating windows where you can embed other UI components.

void WindowButtons(bool minimize, bool close)

  • Description: Shows or hides the window minimize & close buttons.

void Minimize() / void Maximize()

  • Description: Controls the window state.

CustomWindow Example:

CustomWindow win;
LabelUI lab1;
PanelButton but1;

public void Init()
{
win = MS.CustomWindow("System Control");
win.SetPosition(100, 75);
win.SetSize(500, 220);

lab1 = MS.LabelUI("Automatic Mode", win);
lab1.SetPosition(5.0f, 20.0f);

but1 = MS.PanelButton("CLOSE", win);
but1.SetSize(140.0f, 50.0f);
but1.SetPosition(180.0f, 160.0f);
but1.ClickEvent += but1_ClickEvent;

win.Show();
}

public void Finish()
{
but1.ClickEvent -= but1_ClickEvent;
}

void but1_ClickEvent()
{
win.Hide();
}