4 Replies Latest reply on May 12, 2011 2:02 PM by Sorbsbuster

    Custom Dialogue only accepts input via default button

    Sorbsbuster

      Title

      Custom Dialogue only accepts input via default button

      Post

      I want to allow the user to select the number of days to search back, and to specify which table they want to search in.  To do this I have offered a custom dialogue with one input field - the number of days back to search.  The 3 buttons are basically 'Search in Table 1', 'Search in Table 2', and 'Cancel'.  The input field is a global number field.  I default it to '14' and allow the user to overwrite that value.

      The problem is that the over-written value is only accepted when the Default Button is selected.  For example, this simple script will return the overwritten value when the default button is selected, but will only return 14 when either of the other two buttons are selected.

      - Enter Browse Mode
      - Set Field (gNumber ; 14 )
      - Show Custom Dialogue ("Choose a number" ; "What number do you want to use?" ; gNumber )
      - Set Variable ($NumberToShow ; gNumber )
      - Show Custom Dialogue ("The number you entered..." ; "The number you entered was: " & $NumberToShow )

      (Displaying via a $Variable is neither here nor there - showing the gNumber field in the last dialogue shows the same result.)

      My original script is obviously more complex, checking which button was selected to see which table to go to, but the value is collected right at this start of the script.  The result seems really unintuitive.

      I have tried 'Commit Record' after most steps.  I have including a redundant set of 'If' steps, to set the variable if the Get ( LastMessageChoice ) is 1, or 2, or 3, but this makes no difference.  The overwritten value is only ever processed from the default button.

      Any ideas, please?  I don't really want to break it into two steps - asking first for the days' history, and then a second dialogue asking 'Which report?'

        • 1. Re: Custom Dialogue only accepts input via default button
          philmodjunk

          You can use New Window to create your own custom dialog for this and then you no longer are limited to three buttons, nor will only the first button commit the data entered. You can also now format your fields with value lists if that is helpful.

          On the downside, the script gets more complicated, and the new window will have controls in it that a real dialog does not.

          The Known Bugs List database uses New Window as a dialog in several areas. You can download this file and take a look at how it does it. These scripts adjust for window sizing issues if the file is opened on a windows machine. They also adjust their sizes if a windows users selects "enlarge window contents to improve readability" and pauses inside an infinite loop to make the window "modal" (User must close pop up window before returning to main window.).

          Caution: These scripts use the Allow User Abort step to keep the user from canceling the paused script. Unless the buttons/scripts that close this window include Halt Script to halt the original script, they will trap you in a loop that you cannot get out of except by using either the script debugger (fileMaker Advanced only) or by force quitting FileMaker. It's a good idea to leave this step out during testing and then to add it only after you have everything else working like you want.

          • 2. Re: Custom Dialogue only accepts input via default button
            Sorbsbuster

            Thanks for the reply, Phil  "...nor will only the first button commit the data entered" - are you saying that it is a 'feature' that only the default button accepts any user input?  I find that really weird.  I'm happy with the standard dialogue as is, if only it allowed the user-entered data to be picked up no matter which button was pressed.

            • 3. Re: Custom Dialogue only accepts input via default button
              philmodjunk

              Yes, that's how FileMaker designed it to work. I have no idea why they did, but that's why I'm recommending an alternative approach that does not have this limitation.

              • 4. Re: Custom Dialogue only accepts input via default button
                Sorbsbuster

                Before writing the reply, "Well, I'd call it a bug, and at least they might highlight it in the documentation" I thought I'd better check, and unfortunately they do.  The help page for custom dialog says:

                Thanks for clearing that one up for me.