Tostm8 1 Posted December 29, 2017 Hello, I was wondering whether you could create a GUI where the user can input a number? Then that number would be made into a variable that can be used in a script. Thanks! Share this post Link to post Share on other sites
squeeze 22 Posted December 30, 2017 yes I could, I'll assume you can make a gui and are looking for this info....User_Interface_Event_Handlers......displayAddEventHandler 1 Share this post Link to post Share on other sites
HallyG 239 Posted December 30, 2017 This is a quick snippet for you (with comments): h = [] spawn { //--- Wait until the main display exists waitUntil {!isNull findDisplay 46}; //--- Enables us to work with UI data types since we are storing a UI element disableSerialization; _display = (findDisplay 46) createDisplay "RscDisplayEmpty"; //--- Create Edit box _ctrlEdit = _display ctrlCreate ["RscEdit", 19998]; //--- Random width, height etc. not relevant to the overall functionality of this snippet private _width = 20 / 108*safeZoneH /(4/3); private _height = 4 / 108*safeZoneH; private _bufferY = 13 / 108*safeZoneH; private _bufferX = ((safeZoneW / 2) - (_width / 2)); //--- Position the Edit box in the bottom centre of the screen _ctrlEdit ctrlSetPosition [safeZoneX + _bufferX, safeZoneY + safeZoneH - _bufferY, _width, _height]; _ctrlEdit ctrlSetBackgroundColor [0,0,0,1]; _ctrlEdit ctrlCommit 0; //--- Add KeyUp Eventhandler - Fires after the release of any keyboard key _ctrlEdit ctrlAddEventHandler ["KeyUp", { params ["_ctrl", "_key"]; //--- Get text from Edit box _text = (ctrlText _ctrl); //--- poor check to see if input is numeric _isValid = !(parseNumber _text isEqualTo 0) || (count (_text splitString "0123456789.-") isEqualTo 0); //--- Check if the input text is valid if (_isValid) then { _number = parseNumber _text; hintSilent format ["Input: %1", _number]; // [_number] execVM "script.sqf" } else { hintSilent format ["!! Invalid Input !!"]; }; }]; //--- Set input focus to the Edit box ctrlSetFocus _ctrlEdit; }; 2 Share this post Link to post Share on other sites
Tostm8 1 Posted December 31, 2017 Legends! Thanks for the help, both of you. I didn't realise there were UI Event Handlers and that script is just what I need. Thanks again! Share this post Link to post Share on other sites
Tostm8 1 Posted December 31, 2017 New question... I want the GUI to remember that I have disabled a button via "ctrlEnable [_id, false];". How would I do that since when I createDialog for the GUI it goes back to normal? Share this post Link to post Share on other sites