Raybaudi Posted December 30, 2011 Posted December 30, 2011 Little tip ... It often happens that we wish to not allow pasting in a field. It 's simple, just two steps of a script and the trigger OnObjectEnter Set Selection [ Start Position:1 ] Copy [ ] Copyng an empty selection clears the clipboard.
Karsten Wolf Posted December 31, 2011 Posted December 31, 2011 Destroying the user's clipboard is a bad idea in my opinion. I think it would be better to use a custom menu with the "Paste" menu item deleted.
Raybaudi Posted December 31, 2011 Author Posted December 31, 2011 1) If the user is trying to do something not allowed, like enter a different value in a radio button field, I prefer to destroy their clipboard. 2) custom menu works with all the fields of the current layout... and sometimes we need to protect only one field.
Rick Whitelaw Posted January 2, 2012 Posted January 2, 2012 I like this tip. It's probably the only time the word "copy" would appear in a script of mine! RW.
LaRetta Posted January 2, 2012 Posted January 2, 2012 Keep in mind that it will clear a User's clipboard if they simply tab through the field. It might help to remove the field from tab order to offer some protection. Then it will only clear their clipboard if they pop the field. But it will ALWAYS clear the clipboard when the User pops the field even if User does not try to paste. So although I like the concept, I will not switch methods. This is what I have been using to stop paste into a field defined with a value list. If there are flaws (or even downsides) to this technique, I would like to hear them as well. UPDATE: File removed because I made a small change. Please see file below.
Raybaudi Posted January 2, 2012 Author Posted January 2, 2012 1) Show text2 2) Enter something into it 3) Drag from text2 to text BTW: you have hard-coded the ValueList name and this was exactly what DJ didn't want. http://fmforums.com/...post__p__379461 Then it was simpler to validate by value of a value list.
LaRetta Posted January 2, 2012 Posted January 2, 2012 What does this thread have to do with another thread and what one person might have wanted in another thread? Your opening post did not provide the benefits of your solution. If it was to protect from need to hard-code a value list then you should have said that. We do not allow drag and drop in our solutions. I would rather hard-code the value list name (since it is a script parameter attached to the field it addresses) rather than destroy User clipboard simply because they legitimately pop the field. I offered my opinion for other people reading this thread. 2
Raybaudi Posted January 2, 2012 Author Posted January 2, 2012 You explicity asked for flaws or downsides. "We do not allow drag and drop in our solutions" Even so, the user can drag&drop from another app to that field. BTW: the tip for clear the clipboard didn't have anything in common with your example, but your example had many things in common with that other thread. And, if we want to save the clipboard, we could by using Paste [ ] somewhere in the script.
LaRetta Posted January 3, 2012 Posted January 3, 2012 You explicity asked for flaws or downsides. I did. Even so, the user can drag&drop from another app to that field. I was not aware of that, thank you. BTW: the tip for clear the clipboard didn't have anything in common with your example Well thank you. But your opening said, "It often happens that we wish to not allow pasting in a field." Stopping pasting in a field sure seemed to be the subject to me - otherwise why wipe out a User clipboard? My example will work with any field. I used value list because that seemed like good example. What was problem with that? And, if we want to save the clipboard, we could by using Paste [ ] somewhere in the script. Of course but that wasn't in your approach either. I am glad you mentioned it. Listen, Daniele, I told you I liked the concept but that does not mean I agree with your method nor do you have to agree with mine. I said, "I offered my opinion for other people reading this thread" because I wanted to be sure folks were aware that it could be a silent, tabbing, clipboard destroyer if they were unaware of it. That does not mean they shouldn't use your idea (they are big people and they make their own decisions) but I wanted to offer an alternative. Many people post demos in Articles, Tips & Techniques only to have others post different points of view and their suggestions for a technique on same thread. Anyway, the attached small change appears to resolve the issue of external application drag & drop, thanks for catching that. I believe the bottom line (for both of us) is sharing ideas and offering solutions to help people here. As we all know, there are many ways to accomplish same thing and each technique has its good and bad points. I will remove my prior file. NoPasteMOD.zip
Raybaudi Posted January 3, 2012 Author Posted January 3, 2012 dear LaRetta with the premise that I have absolutely nothing against you and always appreciate tips, corrections and improvements, I appreciate your new tones and I hope that we continue on this road.
Newbies Hyperscripter Posted February 22, 2012 Newbies Posted February 22, 2012 I like the idea of this solution, unfortunately I am using FM 6, which does not have a 'set selection' command. Would you have any idea, how I would go about doing this with the commands that I have available in FM 6 ?
Newbies Richard W Graham IV Posted April 1, 2016 Newbies Posted April 1, 2016 how do I use Copy "" in a script? I tried copy and pasting this into it and it won't paste. If I choose copy command I can't add "" to it. I tried a global field with ""in the data box to auto add but that doesn't clear it. instead it copies "" into the field. I tried auto add and empty data box. that didn't work either, funny thing is I know I did this before and it worked but I can't find the file I did it in.
doughemi Posted April 1, 2016 Posted April 1, 2016 Don't use Paste; use Set Field[YourTable::YourField; ""].
Recommended Posts