(RESOLVED) Make an input text dialog box?

Hi,

I’m searching for days for how to make a dialog box like this to enter some text :

Does someone know the name of the native able to do that ?

Thanks in advance

4 Likes

i’m looking for this too. Need an aswer! thanks

Use NUI (not to be confused with Native UI, search forums). NUI uses html/css/js.

2 Likes
DisplayOnscreenKeyboard(false, "FMMC_KEY_TIP8", "", "", "", "", "", 64)
input = true

Then you must have something like this in a while loop because you can only get the input if the results are sent on the same game tick.

if input == true then
	HideHudAndRadarThisFrame()
	if UpdateOnscreenKeyboard() == 3 then
		input = false
	elseif UpdateOnscreenKeyboard() == 1 then
		local inputText = GetOnscreenKeyboardResult()
		if string.len(inputText) > 0 then
			-- Do something with the input
		else
			DisplayOnscreenKeyboard(false, "FMMC_KEY_TIP8", "", "", "", "", "", 64)
		end
	elseif UpdateOnscreenKeyboard() == 2 then
		input = false
	end
end

Refer to the natives:
Display Keyboard - http://www.dev-c.com/nativedb/func/info/00dc833f2568dbf6
Update Keyboard - http://www.dev-c.com/nativedb/func/info/0cf2b696bbf945ae
Get Input - http://www.dev-c.com/nativedb/func/info/8362b09b91893647

3 Likes

I’m not sure that’s NUI which is used in this case, seems to me that this is native from GTA V (and I think I already seen that, but I may be wrong…)
But I will use NUI if there is no solution with native :wink:

Okay, thanks Cosmo, I will try this :smiley:

EDIT :
DisplayOnscreenKeyboard works like a charm, thank you very much !!! :smiley:

2 Likes

It’s just that NUI allows for much more customization. Granted, if all you ever need is a tiny bit of text, NUI might be overkill.

1 Like

hi

Can you show your final code about this input text ?

how you get the input in a table for exemple and about your while loop

thanks

To answer to @Thefoxeur54, I can’t share my scripts right now. All I wanted to know with this post is the name of the function, and with that, I was able to make this dialog box.

To help you a little, I found another code logic on internet (this post) :

DISPLAY_ONSCREEN_KEYBOARD(1, "FMMC_MPM_NA", "", "", "", "", "", 30); // Display the dialog text
while (UPDATE_ONSCREEN_KEYBOARD() == 0) // Loop until the player enters text or exit
{
    DISABLE_ALL_CONTROL_ACTIONS(0);
    WAIT(0);
}
if (!GET_ONSCREEN_KEYBOARD_RESULT()) return; // GET_ONSCREEN_KEYBOARD_RESULT() indicates if the player typed some text
DWORD model = $(GET_ONSCREEN_KEYBOARD_RESULT()); // GET_ONSCREEN_KEYBOARD_RESULT() will return the text input

Now, if you understand this code, you will be able to translate it into lua as all these functions are available.

DisplayOnscreenKeyboard(1, "FMMC_MPM_NA", "", "", "", "", "", 30)
    while (UpdateOnscreenKeyboard() == 0) do
        DisableAllControlActions(0);
        Wait(0);
    end
    if (GetOnscreenKeyboardResult()) then
        local result = GetOnscreenKeyboardResult()
    end

In LUA :wink: and it works perfectly, big thanks :heart:

11 Likes

I’m having an issue with this, I am integrating this into a NativeUI custom menu, But when I press escape when the input box is open, I cant open the menu again. Is there a way to solve this?
And also, is it possible to change the name of the text box?

Hi all, I’m not able to paste text in the box, anyone know if this is possible please? Thanks in advance