RE: [TIP] How to ensure plain pasted text
For those watching this thread, there is a verified bug when focusing out of a field after doing a put into selection: the exitField message is sent instead of the closeField (http://quality.runrev.com/qacenter/show_bug.cgi?id=7354). As a workaround you will need to trap this... local oldMe on openField put the value of the target in oldMe end closeField on exitField if (the value of the targetold) me then send closeField to the target end exitField on closeField [.../...] end closeField on commandKeyDown Vkey if Vkey = v and the selectedField is not empty then put the clipboardData[text] into the selection else pass commandKeyDown end if end commandKeyDown /H ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: [TIP] How to ensure plain pasted text
Hi Hugh Can you elaborate a bit on the problems that you see with my method? I am using it in some places, and plan to use it in the future too, so any backdraw would be of interest to me. Unfortunately I have no clue what you wanted to say. What arrays? Who changes them? I'm not loosing any paragraphs either? Bjoernke PS: Here the second version of my code again, because the original one can't really work in a real project: on commandKeyDown Vkey if Vkey = v and the selection is not empty then put the clipboardData[text] into the selection else pass commandKeyDown end if end commandKeyDown On 24 Oct 2008, at 19:06, Hugh Senior wrote: I'm not sure this holds true for win or linux (or older rev versions then 2.8.1), but on mac os x, when there's styled text in the clipboard, both the html and the text values of the clipboarddata array hold their respective value. Therefore this proved sufficient in one of my projects: on commandKeyDown Vkey if Vkey = v then put the clipboardData[text] into the selection end if end commandKeyDown I believe independent arrays on OSX, as with other platforms, are not supported and changing one will change the others to suit, BvG. You would also lose any paragraph returns, I think. -- official ChatRev page: http://bjoernke.com/runrev/chatrev.php Chat with other RunRev developers: go stack URL http://bjoernke.com/stacks/chatrev/chatrev1.3b3.rev; ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
RE: [TIP] How to ensure plain pasted text
Hi BvG Upon reflexion and trying your handler with both 2.9 and 3.0 in Windows, I prefer your simpler solution over my use of the templateField (although it was an interesting exercise in itself). The loss of paragraphs was the result of my original methodology and manipulations of the clipboardData arrays and is therefore spurious. The only change I would make to your handler is changing 'selection' to 'selectedField' which allows for selected text to be replaced... on commandKeyDown Vkey if Vkey = v and the selectedField is not empty then put the clipboardData[text] into the selection else pass commandKeyDown end if end commandKeyDown Thank you. /H Hi Hugh Can you elaborate a bit on the problems that you see with my method? I am using it in some places, and plan to use it in the future too, so any backdraw would be of interest to me. Unfortunately I have no clue what you wanted to say. What arrays? Who changes them? I'm not loosing any paragraphs either? Bjoernke ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: [TIP] How to ensure plain pasted text
I'm sure your handler will come in useful, but out of interest, would the Edit menu item Paste Unformatted not take care of many of the cases? ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: [TIP] How to ensure plain pasted text
Hi Hugh, What about this: on commandKeyDown theKey if theKey is V and the selectedField is not empty then lock screen paste put the text of the selectedField into the selectedField unlock screen else pass commandKeyDown end if end commandKeyDown (I haven't tested it) -- Best regards, Mark Schonewille Economy-x-Talk Consulting and Software Engineering http://economy-x-talk.com http://www.salery.biz Dutch forum: http://runrev.info/rrforum/ Benefit from our inexpensive hosting services. See http://economy-x-talk.com/server.html for more info. On 24 okt 2008, at 11:24, Hugh Senior wrote: A little something to keep in your Scripter's Scrapbook for when you need it... How do we ensure plain text when we copy and paste from another program? Pasting text from a Browser or an email often results in an unwanted text format that doesn't match the field's default style. This is annoying when all we want is the data not the style, such as a database field. The simplest way is to change the clipboardData which is self- managing... on commandkeyDown pKey if pKey=V then set the clipboardData[HTML] to the clipboardData[TEXT] paste else pass commandkeyDown end commandkeyDown This replaces the clipboard with plain text. It also removes any carriage returns so all the text is now on one line. Good if the field is a one-liner like a phone number; not so good if we want to paste an address. So how do we keep paragraphs intact? This is a solution that uses a powerful, but I suspect often overlooked, feature of Rev: The ability to define default object properties using templates. Rewriting the above we can use... on commandkeyDown pKey if pKey=V then set the htmlText of the templateField to the clipboardData[HTML] set the clipboardData[TEXT] to the text of the templateField reset the templatefield paste else pass commandkeyDown end commandkeyDown We now have plain text on the clipboard including any carriage returns so any paragraph formatting is still there. All we need to do is allow for that one-liner phone number field by checking for the field's autotab property (which we would need to have set anyway)... on commandkeyDown pKey if pKey=V then set the htmlText of the templateField to the clipboardData[HTML] --| Check for one-liner fields and remove carriage returns... if the autoTab of the selectedField then get the text of the templateField replace RETURN with SPACE in it set the text of the templateField to it end if --| set the clipboardData[TEXT] to the text of the templateField reset the templatefield paste else pass commandkeyDown end commandkeyDown That's it. When we paste text, the original clipboardData is stored in the templatefield, which we modified to plain text, then carriage returns are removed if necessary, before updating the clipboardData ready for the 'paste'. For the finishing touches, we should include a couple of tests to make sure it behaves as expected... on commandKeyDown pKey if pKey = V then --| Check if the environment is appropriate... if the tool is NOT browse tool then pass commandKeyDown if the selectedField is empty then pass commandKeyDown if the clipboard is NOT text then pass commandKeyDown --| set the htmlText of the templateField to the clipboardData[HTML] if the autoTab of the selectedField then get the text of the templateField replace RETURN with SPACE in it set the text of the templateField to it end if set the clipboardData[TEXT] to the text of the templateField reset the templatefield paste else pass commandKeyDown end commandKeyDown A final tweak: So far we are assuming that every field is going to be plain text. If we want certain fields only, then we might add a field property called plainTextOnly, and include a test such as... on commandKeyDown pKey if pKey = V then if the tool is NOT browse tool then pass commandKeyDown if the selectedField is empty then pass commandKeyDown if the clipboard is NOT text then pass commandKeyDown --| Check if plain text is required... if the plainTextOnly of the selectedField is TRUE then set the htmlText of the templateField to the clipboardData[HTML] if the autoTab of the selectedField then get the text of the templateField replace RETURN with SPACE in it set the text of the templateField to it end if set the clipboardData[TEXT] to the text of the templateField reset the templatefield end if paste else pass commandKeyDown end commandKeyDown I hope you will find this helpful. ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
[TIP] How to ensure plain pasted text
A little something to keep in your Scripter's Scrapbook for when you need it... How do we ensure plain text when we copy and paste from another program? Pasting text from a Browser or an email often results in an unwanted text format that doesn't match the field's default style. This is annoying when all we want is the data not the style, such as a database field. The simplest way is to change the clipboardData which is self-managing... on commandkeyDown pKey if pKey=V then set the clipboardData[HTML] to the clipboardData[TEXT] paste else pass commandkeyDown end commandkeyDown This replaces the clipboard with plain text. It also removes any carriage returns so all the text is now on one line. Good if the field is a one-liner like a phone number; not so good if we want to paste an address. So how do we keep paragraphs intact? This is a solution that uses a powerful, but I suspect often overlooked, feature of Rev: The ability to define default object properties using templates. Rewriting the above we can use... on commandkeyDown pKey if pKey=V then set the htmlText of the templateField to the clipboardData[HTML] set the clipboardData[TEXT] to the text of the templateField reset the templatefield paste else pass commandkeyDown end commandkeyDown We now have plain text on the clipboard including any carriage returns so any paragraph formatting is still there. All we need to do is allow for that one-liner phone number field by checking for the field's autotab property (which we would need to have set anyway)... on commandkeyDown pKey if pKey=V then set the htmlText of the templateField to the clipboardData[HTML] --| Check for one-liner fields and remove carriage returns... if the autoTab of the selectedField then get the text of the templateField replace RETURN with SPACE in it set the text of the templateField to it end if --| set the clipboardData[TEXT] to the text of the templateField reset the templatefield paste else pass commandkeyDown end commandkeyDown That's it. When we paste text, the original clipboardData is stored in the templatefield, which we modified to plain text, then carriage returns are removed if necessary, before updating the clipboardData ready for the 'paste'. For the finishing touches, we should include a couple of tests to make sure it behaves as expected... on commandKeyDown pKey if pKey = V then --| Check if the environment is appropriate... if the tool is NOT browse tool then pass commandKeyDown if the selectedField is empty then pass commandKeyDown if the clipboard is NOT text then pass commandKeyDown --| set the htmlText of the templateField to the clipboardData[HTML] if the autoTab of the selectedField then get the text of the templateField replace RETURN with SPACE in it set the text of the templateField to it end if set the clipboardData[TEXT] to the text of the templateField reset the templatefield paste else pass commandKeyDown end commandKeyDown A final tweak: So far we are assuming that every field is going to be plain text. If we want certain fields only, then we might add a field property called plainTextOnly, and include a test such as... on commandKeyDown pKey if pKey = V then if the tool is NOT browse tool then pass commandKeyDown if the selectedField is empty then pass commandKeyDown if the clipboard is NOT text then pass commandKeyDown --| Check if plain text is required... if the plainTextOnly of the selectedField is TRUE then set the htmlText of the templateField to the clipboardData[HTML] if the autoTab of the selectedField then get the text of the templateField replace RETURN with SPACE in it set the text of the templateField to it end if set the clipboardData[TEXT] to the text of the templateField reset the templatefield end if paste else pass commandKeyDown end commandKeyDown I hope you will find this helpful. /H ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: [TIP] How to ensure plain pasted text
I'm not sure this holds true for win or linux (or older rev versions then 2.8.1), but on mac os x, when there's styled text in the clipboard, both the html and the text values of the clipboarddata array hold their respective value. Therefore this proved sufficient in one of my projects: on commandKeyDown Vkey if Vkey = v then put the clipboardData[text] into the selection end if end commandKeyDown -- official ChatRev page: http://bjoernke.com/runrev/chatrev.php Chat with other RunRev developers: go stack URL http://bjoernke.com/stacks/chatrev/chatrev1.3b3.rev; ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: [TIP] How to ensure plain pasted text
After a few seconds of thinking (amazing what that can do for you...), I realised that the script as posted is pretty much useless. I transformed an existing script from a rawKeyDown handler of a field, omissing mission critical changes. So for having this done on every field on a card or in a stack the script should look like this: on commandKeyDown Vkey if Vkey = v and the selection is not empty then put the clipboardData[text] into the selection else pass commandKeyDown end if end commandKeyDown On 24 Oct 2008, at 13:55, Björnke von Gierke wrote: Therefore this proved sufficient in one of my projects: on commandKeyDown Vkey if Vkey = v then put the clipboardData[text] into the selection end if end commandKeyDown -- official ChatRev page: http://bjoernke.com/runrev/chatrev.php Chat with other RunRev developers: go stack URL http://bjoernke.com/stacks/chatrev/chatrev1.3b3.rev; ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: [TIP] How to ensure plain pasted text
Thanks Hugh, This was very informative. I have not used the templateField before since I did not think I had a need for it but after this great explanation I think I might find some uses here in the near future. Thanks again, Tom McGrath On Oct 24, 2008, at 5:24 AM, Hugh Senior wrote: A little something to keep in your Scripter's Scrapbook for when you need it... How do we ensure plain text when we copy and paste from another program? Pasting text from a Browser or an email often results in an unwanted text format that doesn't match the field's default style. This is annoying when all we want is the data not the style, such as a database field. The simplest way is to change the clipboardData which is self- managing... Thomas J McGrath III [EMAIL PROTECTED] Lazy River Software http://www.lazyriversoftware.com ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: [TIP] How to ensure plain pasted text
on commandKeyDown pKey if pKey = V then set the htmlText of the templateField to the clipboardData[HTML] if the autoTab of the selectedField then get the text of the templateField replace RETURN with SPACE in it set the text of the templateField to it end if set the clipboardData[TEXT] to the text of the templateField reset the templatefield paste else pass commandKeyDown end commandKeyDown I'm sure your handler will come in useful, but out of interest, would the Edit menu item Paste Unformatted not take care of many of the cases? Not if you have a standAlone and/or are rolling your own, Colin. on commandKeyDown theKey if theKey is V and the selectedField is not empty then lock screen paste put the text of the selectedField into the selectedField unlock screen else pass commandKeyDown end if end commandKeyDown Elegant, Mark, but you would also need to track the insertion point (easily done), and it would not handle any pre-existing user-formatted styles (which I grant you was not part of the exercise but pasting text that defaults to hard-wired Helvetica 14pt is a royal pita). I'm not sure this holds true for win or linux (or older rev versions then 2.8.1), but on mac os x, when there's styled text in the clipboard, both the html and the text values of the clipboarddata array hold their respective value. Therefore this proved sufficient in one of my projects: on commandKeyDown Vkey if Vkey = v then put the clipboardData[text] into the selection end if end commandKeyDown I believe independent arrays on OSX, as with other platforms, are not supported and changing one will change the others to suit, BvG. You would also lose any paragraph returns, I think. /H ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: [TIP] How to ensure plain pasted text
How would this particular menu item and its script magically be created in an app? I'm sure your handler will come in useful, but out of interest, would the Edit menu item Paste Unformatted not take care of many of the cases? -- stephen barncard s a n f r a n c i s c o - - - - - - - - - - - - ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: [TIP] How to ensure plain pasted text
Hi Stephen, If you've copied something, paste unformatted is already in the Edit Menu of 3.0s IDE. Joe Wilkins On Oct 24, 2008, at 3:04 PM, Stephen Barncard wrote: How would this particular menu item and its script magically be created in an app? I'm sure your handler will come in useful, but out of interest, would the Edit menu item Paste Unformatted not take care of many of the cases? -- stephen barncard s a n f r a n c i s c o - - - - - - - - - - - - ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution
Re: [TIP] How to ensure plain pasted text
I know that, but it's useless when one has custom menus in the app. Hi Stephen, If you've copied something, paste unformatted is already in the Edit Menu of 3.0s IDE. Joe Wilkins -- stephen barncard s a n f r a n c i s c o - - - - - - - - - - - - ___ use-revolution mailing list use-revolution@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-revolution