Announcement

Collapse
No announcement yet.

Setting the text of an input on a DialogEx from a DialogEx ?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Setting the text of an input on a DialogEx from a DialogEx ?

    I've got a DialogEx with an input field. Over the input I put a hotspot that shows another DialogEx with a Calendar plugin when clicked.

    When I select a date on the calendar and click the "Close" button, it saves a variable equal to the e_startDate and closes the 2nd DialogEx.

    I want that string to show up in the text of the input field on the first DialogEx when I get back to it. (i.e. the input field / hotspot fires a dialog where the user selects a date, and the date shows up in the input).

    I tried putting the input.SetText in the OnShow for the first DialogEx, but it will only change the input field if I close that (first) DialogEx and then show it again.

    I tried adding the DialogEx.Redraw, but that doesn't seem to work either.

    What am I doing wrong?

    (hope that all makes some sense)

  • #2
    After you closed the second DialogEx, you would use the content of the variable set as the result of the user selection for the Input... No redraw of the dialog is required.

    Ulrich

    Comment


    • #3
      I'm not sure I follow. From what I read, the variable returned from the DialogEx is a number? And it looked like the .Close returns a number to whatever called the .Open

      I actually used that in this fashion (which is probably wrong)....

      in the onShow for the first DialogEx, I have something like...

      if (returnedVariable == 100) then
      input.SetText (--manually set the text for the input to the variable saved from the e_StartDate--)
      end

      I did it this way so the input would only try to set the text if the user had returned from the Calendar and actually picked a date.

      So I'm not real sure what this means...

      "you would use the content of the variable set as the result of the user selection for the Input"

      In my case. the content of the variable is the number 100, and its getting returned from the .Close, to the .Open and making the above "IF" statement true.

      Sorry for not understanding. Thanks as always for the help.

      Comment


      • #4
        When the user makes a selection in your pop-up, you would store this info in a variable. Once the dialog was closed, you would check the contents of that variable, and copy it into the Input field. This is different to the value returned by DialogEx.Close(), which you may not need in your case...

        Ulrich

        Comment


        • #5
          hmmm...

          I just tried this in my onClose for the 2nd DialogEx

          Input.SetText("inputStartDate", startDate);

          But I didn't think the 2nd DialogEx would even know what "inputStartDate" was, since it belongs to the 1st DialogEx.

          Is there a way to reference an object on a different page ?

          example:
          Input.SetText("firstDialogExName.inputStartDate", startDate);

          Thanks

          Comment


          • #6
            No, you didn't understand the explanation. And you cannot reference objects which don't reside on the current page or dialog. This is why I stated that you should store the result in a variable. You cannot do this via Quick Actions, you need to write the script.

            In your Hotspot, you state that you open a DialogEx with the Calendar plugin. So, I assume that you use DialogEx.Show() at some moment. When this code is executed, the script halts there and starts running the code on the DialogEx you just opened instead. The parent Page or DialogEx will not react to any input until the DialogEx is closed - we call this a modal dialog.

            Now, at some point in the scripts of this child DialogEx window, you will need to react to the user input, when he interacts with the Calendar plugin, or else it wouldn't make any sense in showing him that control, right? Now, assume that you store the date(s) selected with

            Code:
            tSelection = Calendar.GetSelection("Calendar1");
            or something similar, perhaps in the On Select event script of the plugin, or in the On Close event script of the DialogEx. Where you do this really doesn't matter and depends on your needs, but you must store the result. Once you close the DialogEx, this is the variable holding the result of the user interaction, which you should use for further processing, right after you opened the DialogEx. So, what you could have in your parent Page or DialogEx could be something like this:

            Code:
            -- open the DialogEx holding the Calendar plugin
            DialogEx.Show("MyCalendarDialog");
            
            -- when we get here, the DialogEx was closed, and we can process the data provided
            if (tSelection ~= nil) then
               Input.SetText("Input1", "The start date provided was " .. tSelection.Begin .. " and the end date was " .. tSelection.End);
            else
               Input.SetText("Input1", "No valid info provided!");
            end
            This is untested code, I just typed it here, so there may be errors, but it should be clear enough to explain how to proceed to get the desired results. If you are still unable to get this running, please post your exported project here.

            Ulrich

            Comment


            • #7
              Wow! I've been using this software for a long time (Join date = 2004, where has the time gone??). But believe it or not, this is my first project using the DialogEx object.

              I understood everything you explained about setting the variable when the user selects a date, and that was the first thing I tried. But I couldn't understand what/when I could trigger that variable to be set to the input.text. That's why I was using onShow and onPreload, etc.

              I had no idea the DialogEx.Show worked more like a function call, rather than a Page.Show. After reading your last post a few times, it made perfect sense that whatever object (button, hotspot, etc) "calls" the DialogEx will continue to execute the code after the DialogEx is closed.

              I'm really glad I reached out to this forum for help. I had already figured a different way to achieve what I needed, but I'm scrapping that and going back to the original idea now that I fully understand how the DialogEx works. This really changes the way I will make projects in the future.

              Thanks again for your patience!

              Comment

              Working...
              X