Jump to content

llDialog with llTextBox help


Wallee Rae
 Share

You are about to reply to a thread that has been inactive for 1153 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Does anyone have a working example of using llTextBox with llDialog menu to accept user input after clicking a menu choice? I need to use the message response from the llTextBox Submit and perform follow on actions using the message value.

Thanks in advance, Wallee

Link to comment
Share on other sites

thanks so much for the link!  Had found it previously, tried it out and it works great, but that example does not show how to use it with llDialog so that the script can capture manually entered input from the TextBox after the user clicks a menu item in a dialog menu that popups the TextBox.  I need to capture that input and use the value entered by the user in other places within the script.

I tried merging the code from the example into my dialog script but cannot get it to work so was wondering if anyone else was able to do this.

Wallee

Link to comment
Share on other sites

Think it through.   You know how llDialog works -- present a menu with options and something happens in the listen event, depending on which option the use chooses.

listen(integer channel, string name, key id, string message){	if ("Red" == message){		llSetColor(<1.0,0.0,0.0>;	}}

In this case you want to pop up a text box rather than turn the prim red, so you need something like 

listen(integer channel, string name, key id, string message){	if ("Text Box" == message}	{		llTextBox(id, "Please enter a message and click Submit", iSomeChannel);	}}

You need some way of identifying the free-form message you receive from the text book.   One simple way to do it is to check whether the message is one of the ones you expect from the llDialog menu, using llLIstFindList.

If it's not, then it should be safe to assume it's a response entered in the text box.

Another way to do it would be to use one channel for llDialog and another for llTextbox.    That's probably the simplest.

  • Like 3
Link to comment
Share on other sites


Innula Zenovka wrote:

Another way to do it would be to use one channel for llDialog and another for llTextbox.    That's probably the simplest.

i vote for this way. Is like you say simpler and makes our code quite a bit safer as well

safer in the sense that if/when the user enters the name of a button in the textbox then can play havoc sometimes [if/when using the same channel for both]

eta [ ]

Link to comment
Share on other sites

  • 3 years later...
        user = llDetectedKey(0);
        listen1 = llListen(-99, "", user, "");
        llDialog(user, "\nThis is it kiddo!\n You can add upto 4 babies", ["Setup", "Begin Tracking","Exit" ] , -99);
    }
    listen(integer chan, string name, key id, string msg){
        if (msg == "Exit"){
            llSay(0,"Closing...");
            close_stuff();
        }
        if (msg == "Setup"){
            llDialog(user, "\nAdd Names\n You can add upto 4 babies", ["2nd Baby", "3rd Baby","4th Baby","1st Baby","Back" ] , -99);
        }
        if(msg=="Back"){
            llDialog(user, "\nThis is it kiddo!\n You can add upto 4 babies", ["Setup", "Begin Tracking","Exit" ] , -99);
        }
        if(msg=="1st Baby"){
            llTextBox(user, "Enter the EXACT Name of the 1st Baby...", -99);
            llSleep(60);
            mdesc=msg;
            llSay(0,"baby is:"+mdesc);
        }
    }

the textbox thing is not working in the above code.

any ideas why?

Link to comment
Share on other sites

The listen only responds to the four choices specified in the if clauses, so when it hears the results of the text box it has no way of processing the message, as it will not be matched by any of the if tests.

What you might try is setting a global variable to some value when you are specifiying a textbox input, change your ifs to a set of if ... else if ... and at the very end have an else ... clause.

When you get to the else clause none of the four known commands have been recognised so it is possibly a textbox input, query the global variable to see if that is what is expected, and process the message value accordingly. Then reset the global variable to show you are no longer waiting for a textbox input.

 

By the way, picking up a very old post such as this one from 2016 and using it as the basis for your query might seem logical, but there are some people who go into the screaming ab-dabs whenever they see an instance of necro-posting. Myself, I'm not averse to digging up the dead, but be warned, others are :)

Edited by Profaitchikenz Haiku
  • Like 1
Link to comment
Share on other sites

I agree that the sleep could result in the listen event not hearing the result of the text box (but I suspect the events are queued for the script while it is sleeping so it gets them when the sleep ends?), but in this instance the listen event is coded to only react to four specific strings, if the message is not one of exit, setup., back or 1st baby then the message will be ignored.

 

ETA you were right, the sleep causes the listen to miss the text box answer. Unless the user waits that length of time before pressing send  (I proved it by cutting the sleep to 20 seconds, counting out time, then gave the baby's name, and it worked, but responding instantly didn't work.)

 

So this works as the OP (recent OP) wanted it to...

// test a text box for the forums

key owner;

integer lHandle;
integer chan = -99;

string action;

default
{
    state_entry()
    {
        owner = llGetOwner();
    }

    touch_start(integer touches)
    {
        key toucher = llDetectedKey(touches - 1);
        
        if( toucher == owner)
        {
            action = "";
            llDialog(toucher, "Choose from: ", ["Setup", "Begin tracking", "Exit"], chan);
            lHandle = llListen(chan, "", toucher, "");
        }
    }
    listen(integer ch, string name, key id, string msg)
    {
        integer more = 0;   // unless specified, this is the end of the listen
        if(msg == "Exit")
        {
            llSay(0, "Closing...");
            // do close stuff
        }
        else if( msg == "Setup")
        {
            more = 1;
            llDialog(id, "Add names ", ["2nd Baby", "3rd Baby", "4th Baby", "1st Baby", "Back"], chan);
        }
        else if( msg == "Back")
        {
            more = 1;
            action = "";
            llDialog(id, "This is it...", ["Setup", "Begin Treacking", "Exit"], chan);
        }
        else if( msg == "1st Baby")
        {
            action = "1st Baby";
            llTextBox(id, "Enter the exact name ", chan);
            more = 1;
            //llSleep(20.0);
        }
        else
        {
            // probably names
            if( action == "1st Baby")
            {
                llSay(0, "1st baby is called " + msg);
                action = "";
            }
        }
        if( more != 1)
        {
            llListenRemove(lHandle);
        }
        
    }
}

 

Edited by Profaitchikenz Haiku
added code
  • Like 1
Link to comment
Share on other sites

2 hours ago, Profaitchikenz Haiku said:

I agree that the sleep could result in the listen event not hearing the result of the text box (but I suspect the events are queued for the script while it is sleeping so it gets them when the sleep ends?), but in this instance the listen event is coded to only react to four specific strings, if the message is not one of exit, setup., back or 1st baby then the message will be ignored.

 

ETA you were right, the sleep causes the listen to miss the text box answer. Unless the user waits that length of time before pressing send  (I proved it by cutting the sleep to 20 seconds, counting out time, then gave the baby's name, and it worked, but responding instantly didn't work.)

 

   Thank you. I wasn't sure whether or not event queueing happens during a script sleep period. Now I know.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1153 days.

Please take a moment to consider if this thread is worth bumping.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...