Surface_InputButtonPressed
Skip to content
mnscript
Surface_InputButtonPressed(MNGuiInputButton, Player, string) 

Description ​

Invoked when a Surface UI input button is pressed.

Arguments ​

MNGuiInputButton - The MNGuiInputButton which was pressed.
Player - The Player who pressed the button.
string - The text which was input.

Example ​

msc
using Console;
using Event;
using Player;
using Surface;

// Create the application UI

MNGuiFrame frame = Surface.CreateApplicationFrame();
MNGuiPanel pnl = frame.GetPanel();

// Create a button which prints the user input to the console

MNGuiInputButton button = Surface.CreateInputButton(pnl);
button.SetText("Input");
button.SetTag("InputButton");
button.SetTitle("Say Something");

// Make sure to update the UI so the button appears on the screen.
Surface.Update();

// Make the event for when the button is pressed

function OnSurfaceInputButtonPressed(MNGuiInputButton button, Player player, string text){
    if(button.GetTag() == "InputButton"){
        Console.WriteLine(player.GetName().." says: "..text);
    }
}

Event.AddListener("Surface_InputButtonPressed", "surface_input_buttons", "OnSurfaceInputButtonPressed");

while(true){
    Event.Process();
}