Jump to content

DialogGUITextInput ?


Recommended Posts

I could be mistaken, but I believe that is the descriptive text that appears in a text field but is not returned as part of the entered data.

For example, in the VAB/SPH part search box, the phrase "Enter Search..." appears in the box.  That is the place holder.

Link to comment
Share on other sites

@HebaruSan helped me with this so can't take credit but this is how he got it to work.

Custom_Contract_Input = new DialogGUITextInput(SaveInfo.crewTransferName,false,200,(string s) => 
{
SaveInfo.crewTransferName = s;
return s;
}, 30f);

all you need to do is Return the string your trying to change.. And in my case the value is Persistent so it saves automatically. It uses LambaExpression to return String S as SaveInfo.crewTransferName.  

Link to comment
Share on other sites

so... the callback is for relaying the text input to whatever routine, and the return value is unnecessary for the routine to work, but still requires it.

seems pointless to have a return value. why not just a void?

Edited by Xyphos
Link to comment
Share on other sites

36 minutes ago, Xyphos said:

so... the callback is for relaying the text input to whatever routine, and the return value is unnecessary for the routine to work, but still requires it.

seems pointless to have a return value. why not just a void?

I think it's for when you want to control the allowed input, like a character limit or filename formatting or maybe some form of auto-completion.

Link to comment
Share on other sites

4 hours ago, Xyphos said:

so... the callback is for relaying the text input to whatever routine, and the return value is unnecessary for the routine to work, but still requires it.

seems pointless to have a return value. why not just a void?

For me this was one of those spots where OnGui was better.  I couldn't make heads tails out of the why its this way either.  But it is what it is. And it works at this point. And nothing else worked it seems.  At least with my limited knowledge.

Edited by malkuth
Link to comment
Share on other sites

5 hours ago, HebaruSan said:

I think it's for when you want to control the allowed input, like a character limit or filename formatting or maybe some form of auto-completion.

Well, I've tried it, and that's not the case.


                var inputDeltaV = new DialogGUITextInput(
                    "",
                    "0 m/s",
                    false,
                    8,
                    s =>
                    {
                        var i = 0;
                        if (int.TryParse(s, out i))
                            MinimumDv = i;
                        else
                            deltavInput.text = MinimumDv.ToString();

                        return MinimumDv.ToString();
                    },
                    32f
                    );

 

the result of testing:

wMkk3mU.jpg

if seems the callback was given a code signature of Func<string, string>

perhaps it's a typo on the dev's part? maybe it should be just Func<string>

providing a returned value doesn't seem to do anything.

return "French Fries" // does nothing
return "" // does nothing
return null; does nothing


 

Link to comment
Share on other sites

Well, after some testing, I can't figure out how to validate the input - if I want a number-only field, I can get the text just fine, but setting that text doesn't seem to have any effect.

Link to comment
Share on other sites

I think this is another case where the DialogGUI system is just being an awkward workaround for a proper UI. Regular text input fields have events that you can subscribe to, or you can store a reference to the text value, and you have lots of control over the input types allowed along with things like the max number of characters.

I think you can control most of this by grabbing the TMP_InputField component from the DialogGUITextInput.uiItem. Then you can just edit the relevant properties to your liking.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...