4 Replies Latest reply on Apr 6, 2016 11:27 AM by ninja

    Paste unformatted text by default

    anothersmurf

      I'm trying to make it easier for users to paste into the DB without unwanted text formatting. Status quo is they have to paste then undo, or remember to use the special "Paste Without Formatting", or call me and ask for help. All of these methods work, but they're kind of a pain.

       

      Since I can create/modify menus, I figured I'd just rename Paste Without Formatting as "Paste" and change the keyboard command to match. While I was at it, I changed "Paste" to "Paste With Formatting", and gave it a different keyboard command, to get it out of the way but leave it as an option if needed.

       

      This worked exactly as desired on every layout. However, when the cursor isn't on a layout, e.g. when editing a calculation or in the password-entry field when opening a DB. Paste no longer works. It just beeps. Only "Paste Without Formatting" works. So the problem is that my menu modification takes effect in places where it shouldn't...

       

      There's a way to make menu items appear only conditionally, so I need a condition that's true only when a database window is active, and isn't true when editing a calc, opening a DB, etc. Unfortunately, I couldn't find such a conditional. "windownames" excludes all of the windows that I want to exclude, so that's no good. get(currentlayout) doesn't change when the active window isn't a layout window, so that doesn't work either.

       

      Can anyone suggest a way to alter a menu item only on layouts, and not elsewhere? Or some other way to safely make unformatted pasting the default?

        • 1. Re: Paste unformatted text by default
          ninja

          You can set the target field as an Autoenter Calculation...(uncheck the do not replace...)

           

          And then have the calculation be TextFormatRemove(Self)

           

          It won't paste unformatted...but it will remove the formatting once the paste operation is complete.

          1 of 1 people found this helpful
          • 2. Re: Paste unformatted text by default
            hbrendel

            Change the menu item...

            • 3. Re: Paste unformatted text by default
              anothersmurf

              That's a much better way of accomplishing something I tried with a script trigger (and certainly better than nothing). But it has some of the same disadvantages: it needs to be set up for each field individually, it prevents text from ever being formatted (even if desired), and the user sees the formatted text until exiting the field.

               

              I tried replacing Paste with a two-step script, Paste and Commit. That way the user sees unformatted text right away, but it still broke Pasting in non-DB windows, so no good.

              • 4. Re: Paste unformatted text by default
                ninja

                FWIW, I have some duplicate fields in one of my solutions...a place where I need the text formatted on one layout, but unformatted on a different layout...two different fields.

                 

                User can only access one of the fields (FieldUnformatted).

                OnModify for the unformatted, I set the other field to the formatting I want (which may differ from record to record based on other criteria).

                 

                That leaves the Dbase (ie. me)  in control of formatting...instead of the user.

                Users can paste in whatevr they want...I strip the formatting then apply my own through the autoenter and the OnModify script.