14 Replies Latest reply on Apr 22, 2010 3:16 PM by comment_1

    How do you do this?

    mattb

      Title

      How do you do this?

      Post

      I've got a textbox which is read-only, i.e. I've unchecked "Browse" mode in the Behavior pallette on the Inspector (FMP 11).  I have the scroll bar turned on because the amount of text is larger than the textbox size.  However in this read-only mode, the scrollbar does not work.  I would like to be able to have a read-only field where the user cannot enter text but can scroll to the bottom to see all content.  There must be a way to do this!  What am I doing wrong?

       

       

       

      Matt Bloomfield

        • 1. Re: How do you do this?
          Steve Wright

          Theres a few ways you could do this.

           

          This one I have not tried (just thought of it) 

          1. Allow the field to be entered.

          2. Run a script trigger for onObjectEnter to capture the fields contents into a global variable

          3. Run a script trigger for onObjectExit to restore the fields contents from the variable.

           

          Or..

           

          Create a calculated field to display the contents.. you then get an annoying dialog stating the field cannot be modified if you try and type in it, but this can be supressed, take a look here : http://forum-en.filemaker.com/t5/Using-FileMaker-Pro/A-Tip-Prevent-Dialog-Before-Typing-press-Tab-or-Click-in-a-field/m-p/49633

          • 2. Re: How do you do this?
            mattb

             


            SWS wrote:

            Theres a few ways you could do this.

             

            This one I have not tried (just thought of it) 

            1. Allow the field to be entered.

            2. Run a script trigger for onObjectEnter to capture the fields contents into a global variable

            3. Run a script trigger for onObjectExit to restore the fields contents from the variable.

            -------------------------------------------------------------------------------------------------------------------------

             

            I see what you're getting at with this, but it would allow the user to type in anything and having

            the script trigger revert the data when exiting.  But I don't want the user to be able to type anything

            in in the first place

             

            ---------------------------------------------------------------------------------------------------------------------------

            Or..

             

            Create a calculated field to display the contents.. you then get an annoying dialog stating the field cannot be modified if you try and type in it, but this can be supressed, take a look here : http://forum-en.filemaker.com/t5/Using-FileMaker-Pro/A-Tip-Prevent-Dialog-Before-Typing-press-Tab-or-Click-in-a-field/m-p/49633

             

            --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

            Unfortunately I can't make use of this because I can't have a pre-defined calculated field.  The contents of this read-only field is determined by the user selecting a choice from a dropdown list at runtime.

             

            Any other ideas to achieve this end? 

             

             

             

            Matt Bloomfield


             

             


            • 3. Re: How do you do this?
              raybaudi

              mattb wrote:

              Unfortunately I can't make use of this because I can't have a pre-defined calculated field.  The contents of this read-only field is determined by the user selecting a choice from a dropdown list at runtime.


              If the contents of that field is determined by the user selecting a choise, the field CAN be a calculated field.

               

              • 4. Re: How do you do this?
                mattb

                 


                raybaudi wrote:

                mattb wrote:

                Unfortunately I can't make use of this because I can't have a pre-defined calculated field.  The contents of this read-only field is determined by the user selecting a choice from a dropdown list at runtime.


                If the contents of that field is determined by the user selecting a choise, the field CAN be a calculated field.
                ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
                OK, how?  If I define the field as "Calculation" as opposed to plain old "Text", it wants me to specify the the calculation formula at design time.  Keep in mind I don't really care how I get there, but my primary aim here is to have a read-only field where the user cannot type in anything yet the scrollbar on this read-only field is active.  The idea behind the calculated field as suggested by SWS is that calculated fields won't allow user input at runtime...
                Matt Bloomfield

                 

                 


                • 5. Re: How do you do this?
                  comment_1

                  User selecting from a dropdown is one field (not a calculation field).

                  Displaying the selected data is another (a calculation field).

                   

                  Perhaps you should explain in more detail what you're trying to accomplish here. If users cannot enter data, how is the field (or fields?) populated?

                  • 6. Re: How do you do this?
                    mattb

                     


                    comment wrote:

                    User selecting from a dropdown is one field (not a calculation field).

                    Displaying the selected data is another (a calculation field).

                     

                    Perhaps you should explain in more detail what you're trying to accomplish here. If users cannot enter data, how is the field (or fields?) populated?


                    OK.  I have a screen which contains a dropdown list with about 25 different choices.  Depending on what the user chooses, I am populating another field (currently via an OnObjectModify script trigger) with a concatenation of text from between 2-5 separate fields in the table.  This works just fine right now.  The problem I am having is that the textbox which displays this concatenated data is necessarily smaller than the data being displayed, which means a vertical scrollbar is necessary.  That's fine except I want to have this field be read-only.  When I uncheck the Browse mode checkbox, it does make this textbox read-only but it also disables the scroll bar.  What I'm after here is a read-only textbox where the scrollbar is functional so users can see all the data but not enter anything new.
                    Whether this end result can be achieved by using a Calculation field or by some other means is irrelevant to me - I'm just looking for functionality that I just described.  SWS suggested using a Calculation field because that prevents user input.  But to my understanding, Calculation fields must have the calculation pre-defined at design time and since the data in this field is populated at runtime by a user selection, I don't think this is a viable solution.  However, I am open to any and all suggestions, as long as the end result is a read-only textbox with a functioning scrollbar!
                    Matt Bloomfield


                     

                     


                    • 7. Re: How do you do this?
                      Steve Wright

                      As comment asked, if the field displaying the data is not calculated, and can not be entered.. how is it getting its data, is it a lookup or being set by a script trigger ?

                       

                      Either way, lets say you have table::Field1, which is the plain text field you wish to protect...

                      Add a new Calculation Field,  table::calc_Field1 with the calculation simply referencing the plain text field, i.e   table::Field1

                       

                      You can then place calc_Field1 on the layout instead if Field1 and allow entry into the field along with the scroll bar.

                      Of course, if a user tries to type, they will receive the 'field cannot be modified' dialog box, which you can suppress as I mentioned earlier.

                       

                      Edit : Also set the new calculation field as unstored.

                      • 8. Re: How do you do this?
                        mattb

                         


                        SWS wrote:

                        As comment asked, if the field displaying the data is not calculated, and can not be entered.. how is it getting its data, is it a lookup or being set by a script trigger ?

                         

                        ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

                        It's a script trigger that is activated by user choice from a dropdown list.  The protected field is actually a concatenation of anywhere between

                        2-5 existing text fields.  But the main problem is that it is populated at runtime by the user's choice so I don't think I can use a Calculation field

                        that is defined at design time because the exact calculation can't be known until the user makes the dropdown selection and the script trigger is activated.  Unless there's something I don't fully understand about Calculation fields - that's entirely possible.

                         

                         

                         

                        Matt Bloomfield

                         

                         

                        • 9. Re: How do you do this?
                          (O_O)

                          You can have the text field hidden from view (ie underneath a white box with no borders on the side), and create an unstored calculation equal to the text field that is placed where the text field is suppose to be located with a scrollbox.  The script will still populate the textbox and then the calculation will be populated based on the filling in of the textbox.

                           

                          I believe that SWS is trying to take into account the lookups and such autoenter fields could change the situation.

                           

                          Personally, I think this is a bug and there should not be a need for this workaround, but maybe it's just me.  :)

                          • 10. Re: How do you do this?
                            Steve Wright

                             


                            mattb wrote:

                             

                            It's a script trigger that is activated by user choice from a dropdown list.  The protected field is actually a concatenation of anywhere between

                            2-5 existing text fields.  But the main problem is that it is populated at runtime by the user's choice so I don't think I can use a Calculation field

                            that is defined at design time because the exact calculation can't be known until the user makes the dropdown selection and the script trigger is activated.  Unless there's something I don't fully understand about Calculation fields - that's entirely possible.

                             

                             


                             

                             

                            The calculation only needs to contain the Table and Field Name which contains the actual data, therefore it will work at runtime...regardless of how you are populating the field.

                             

                            The exact calculation would only be table::field nothing more... set as an un-stored calculation, it will update itself when required.

                             

                            As Oki suggested, it would be good if there was no need for workarounds and that a scroll bar still worked when entry into field was disabled, but there's no way to achieve that without having allow entry in browse mode enabled.

                             

                             

                            Anyway... Try it... you will see.

                             


                            • 11. Re: How do you do this?
                              mattb

                               


                              SWS wrote:

                               

                              The calculation only needs to contain the Table and Field Name which contains the actual data, therefore it will work at runtime...regardless of how you are populating the field.

                               

                              The exact calculation would only be table::field nothing more... set as an un-stored calculation, it will update itself when required.

                               

                              As Oki suggested, it would be good if there was no need for workarounds and that a scroll bar still worked when entry into field was disabled, but there's no way to achieve that without having allow entry in browse mode enabled.

                               

                              Anyway... Try it... you will see.

                               


                               

                               

                              OK, help me out here, please!  I set the read-only field in question to be Calculation unstored, return value Text.  I set the initial calculation

                              to be an empty field in the table because I want this box to be blank until the user makes a choice from the dropdown.

                               

                              Once the user makes a choice from the dropdown, an OnObject Modify script trigger is used to run a script.  The script simply

                              sets a variable with the contents of Field A + Field B.  I was then using a Set Field command to stuff this read-only field when it was

                              designated as Text and it worked fine then, but now that it's a Calculation field I get the "This action cannot be performed because this

                              field is not modifiable" error message the moment it hits the Set Field script step.  I tried changing the Set Field to the Insert

                              Calculated Result script step with the same results.

                               

                              So now I cannot update the unstored calculation and stuff this field with the new value based on the user choice.  What am I doing wrong?

                               

                               

                               

                              Matt Bloomfield


                              • 12. Re: How do you do this?
                                fitch

                                You can either make the calc field's calculation:

                                Field A + Field B

                                 

                                Or you can keep your existing field where you were writing that data, let's call it Field C.

                                 

                                Now make Field D (the display field) whose calc is:

                                Field C

                                 

                                Another option is to use a web viewer to display the calculated value (with or without field C).

                                • 13. Re: How do you do this?
                                  mattb

                                   


                                  Fitch wrote:

                                  You can either make the calc field's calculation:

                                  Field A + Field B

                                   

                                  Or you can keep your existing field where you were writing that data, let's call it Field C.

                                   

                                  Now make Field D (the display field) whose calc is:

                                  Field C

                                   


                                  Yes!  This was the missing puzzle piece - thanks!
                                  SWS - I only needed the one line of your dialog box suppression script which was:
                                  Exit Script [Result: False] 

                                   

                                   

                                  However, even though that worked, it left the displayed calculation field with a blue selection highlight on all the data, so I added:

                                   

                                  Set Selection [Table::CalcField; Start Position: 0; End Position: 0]

                                   

                                  before the Exit Script line and now I have exactly the behavior I was seeking when I first started this thread.

                                   

                                  As an editorial aside, adding to others' similar comments, it's quite bizarre to me (coming to FMP from Visual Foxpro) to have to go to so

                                  much "workaround trouble" to get the end result...

                                   

                                   

                                   

                                  Matt Bloomfield

                                  • 14. Re: How do you do this?
                                    comment_1

                                     


                                    mattb wrote:

                                     it's quite bizarre to me (coming to FMP from Visual Foxpro) to have to go to so

                                    much "workaround trouble" to get the end result...


                                     

                                    You don't have to. As Tom mentioned, instead of using a script to set field to a calculated result,  you can make the field a calculation field using the same formula. Then you won't need a second field to display the result