Re: Scripting Cut/Copy/Paste in custom menus
On Mon, Sep 15, 2014 at 12:49 PM, J. Landman Gay jac...@hyperactivesw.com wrote: Forgot to mention: the IDE uses the delete command in it's Clear menu item script, but only applies it for objects. It scripts the deletion of text in fields, and that too fails to provide a closefield message. I'm sure I checked that and it was different in the IDE but when I check it again you are right. Submitted a suggestion for a Dictionary amendment. Bug 13440 ... The Dictionary entry for closeField AND delete should also include these two other exceptions of when closeField will not be triggered: i.e. The closeField message is not sent when a field's content is changed by: * using the put command * using the delete command, or it's synonym; clear * using the IDE's Clear Text menu item ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Scripting Cut/Copy/Paste in custom menus
Bob, Cut, copy, paste clear are available as commands in LC, so maybe simplifying your Edit menu a little may help, for example… --The following menuPick handler was generated by the Menu Builder ( simplified a little). on menuPick pWhich switch pWhich case Preferences --Insert script for Preferences menu item here break default do pWhich end switch end menuPick …It works for what you are describing as far as I can see, although it's not perfect. Tested in LC 5.5.5 + 6.6.2 7.0(rc1) on Mac OS X 10.9.3 Cutting, or pasting within a field then tabbing out does trigger a closeField message, but Copy doesn't, possibly because the field didn't change even though the field still closed on tab, it does trigger an exitField. However, Clear doesn't trigger a closeField message for some odd reason, but it does trigger an exitField, that seems a little inconsistent to me, because the contents of the field did change before exiting in much the same way that cut changes the field, I realise the Cleared text doesn't go onto the clipboard, but the effect on the field is the same. So as far as I can see, Clear is the only case you would need to add a script for the lack of closeField. If anybody else sees the inconsistency with the Clear command as a bug, I would be happy to make a sample stack and report it, I'd just like to be sure I'm seeing it right before I do. Paul On Sep 13, 2014, at 5:55 PM, Bob Sneidar bobsnei...@iotecdigital.com wrote: First, if I cut or paste something in a field then tab out, closeField is not triggered. ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Scripting Cut/Copy/Paste in custom menus
On Sat, Sep 13, 2014 at 8:26 PM, J. Landman Gay jac...@hyperactivesw.com wrote: on closeField doStuff end closeField And in some other handler somewhere: put xyz into fld 1 doStuff or even -- Dr. Richard E. Hawkins, Esq. (702) 508-8462 ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Scripting Cut/Copy/Paste in custom menus
Let'st try that again . . . On Sun, Sep 14, 2014 at 7:45 AM, Dr. Hawkins doch...@gmail.com wrote: On Sat, Sep 13, 2014 at 8:26 PM, J. Landman Gay jac...@hyperactivesw.com wrote: on closeField doStuff end closeField And in some other handler somewhere: put xyz into fld 1 doStuff or even Ore even -- Dr. Richard E. Hawkins, Esq. (702) 508-8462 ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Scripting Cut/Copy/Paste in custom menus
On Sun, Sep 14, 2014 at 2:22 PM, Paul Hibbert paulhibb...@mac.com wrote: Tested in LC 5.5.5 + 6.6.2 7.0(rc1) on Mac OS X 10.9.3 Cutting, or pasting within a field then tabbing out does trigger a closeField message, but Copy doesn't, possibly because the field didn't change even though the field still closed on tab, it does trigger an exitField. Test this - and it's been this way ever since I can remember - Rev 1.1.1. What Bob is complaining about is, Create a New stack, 2 fields, in the second field put: on closeFiield beep end closeField. Type a couple of chars into the first field. Use the IDE built in Copy and Paste commands. Copy a different char from the first field and Paste into the 2nd. Then press Tab. LC will Beep as expected. Now use the Menu Builder to create an OS X Menu for you, tick the box to Set as stack Menu Bar, have it auto build the script for you, and then open if for Edit and fill it as you would for Copy, Paste, and Clear. It should look something like this: --The following menuPick handler was generated by the Menu Builder. on menuPick pWhich --breakpoint switch pWhich case Cut --Insert script for Cut menu item here break case Copy set the clipboardData[Text] to the selectedText of the focusedObject break case Paste put clipboardData[text] into the focusedObject break case Clear put empty into the focusedObject break case Preferences --Insert script for Preferences menu item here break end switch end menuPick Do exactly the same as you did before. After you Paste and Tab or Clear and Tab LC will NOT Beep. Jacque mentions the textChange message but this is a message not a property and frankly I have a problem with using a message or Jacques solution (although it might be prefectly fine for what you are doing) because it means LC will go ahead and do things BEFORE you've asked it to do so. i.e in the above example I can get LC to beep but it's BEFORE I've tabbed out. To me, in the first instance, using the IDE Copy, Paste, and Clear I'm assuming an inbuilt property is being set so LC knows the field is dirty and so correctly triggers the closeField message on Tab - unfortunately I have no idea what that property is so I can't use it. So I use a simple workaround of creating my own Custom Property to do the same thing - the big difference though is I have to test my dirty custom prop in an exitField message. --The following menuPick handler was generated by the Menu Builder. on menuPick pWhich --breakpoint switch pWhich case Cut --Insert script for Cut menu item here break case Copy set the clipboardData[Text] to the selectedText of the focusedObject break case Paste put clipboardData[text] into the focusedObject set the cIsFldDirty of the focusedObject to true --* break case Clear put empty into the focusedObject set the cIsFldDirty of the focusedObject to true --* break case Preferences --Insert script for Preferences menu item here break end switch end menuPick Place in any effected fields you want to check: on closeField --do what you need to here beep end closeField on exitField if (the cIsFldDirty of me = true) then --* --content change by paste/clear so do closefield set the cIsFldDirty of me to false --* send closeField to me else --content hasn't changed --probably don't need to do anything end if end exitField If you do not have to do this in Win or Linux, then maybe it's a BUG for OS X but as I say it's work this way for as long as I can remember. ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Scripting Cut/Copy/Paste in custom menus
On Sun, Sep 14, 2014 at 2:22 PM, Paul Hibbert paulhibb...@mac.com wrote: Cut, copy, paste clear are available as commands in LC, so maybe simplifying your Edit menu a little may help, for example… OK, now I see what you are saying, if you build your Menu Bar script using the basic Cut, Copy, Paste, and Clear commands like this: on menuPick pWhich switch pWhich case Cut cut break case Copy copy break case Paste paste break case Clear clear break case Preferences --Insert script for Preferences menu item here break end switch end menuPick Then you get exactly the same behaviour as using the IDE menu except for 'clear'. That does seem a bug. I have used the clipboardData for so long that I'd forgotten the basics. I've found the ability to check what type of data is stored in the clipboardData array and test against the target to determine if the data can be pasted there, or if there are several types of data that can be pasted (text vs html vs rtf vs unicode) allow the option to choose, is just super powerful. I can't remember the last time I used the standard paste command. Sorry for any confusion caused. ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Scripting Cut/Copy/Paste in custom menus
On 9/14/2014, 9:41 PM, Kay C Lan wrote: Now use the Menu Builder to create an OS X Menu for you, tick the box to Set as stack Menu Bar, have it auto build the script for you, and then open if for Edit and fill it as you would for Copy, Paste, and Clear. It should look something like this: --The following menuPick handler was generated by the Menu Builder. on menuPick pWhich --breakpoint switch pWhich case Cut --Insert script for Cut menu item here break case Copy set the clipboardData[Text] to the selectedText of the focusedObject break case Paste put clipboardData[text] into the focusedObject break case Clear put empty into the focusedObject break case Preferences --Insert script for Preferences menu item here break end switch end menuPick Do exactly the same as you did before. After you Paste and Tab or Clear and Tab LC will NOT Beep. I think the magic message you're looking for is just to use the standard LC commands that are available. When I create a menu like this it works as expected: --The following menuPick handler was generated by the Menu Builder. on menuPick pWhich switch pWhich case Cut cut break case Copy copy break case Paste paste break case Clear clear break case Preferences --Insert script for Preferences menu item here break end switch end menuPick -- Jacqueline Landman Gay | jac...@hyperactivesw.com HyperActive Software | http://www.hyperactivesw.com ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Scripting Cut/Copy/Paste in custom menus
Except Paul is right, on OS X the clear command in a custom built menu does not invoke a closeField message which it does if using the IDE's clear command. This does seem to be a bug. On Mon, Sep 15, 2014 at 12:15 PM, J. Landman Gay jac...@hyperactivesw.com wrote: On 9/14/2014, 9:41 PM, Kay C Lan wrote: Now use the Menu Builder to create an OS X Menu for you, tick the box to Set as stack Menu Bar, have it auto build the script for you, and then open if for Edit and fill it as you would for Copy, Paste, and Clear. It should look something like this: --The following menuPick handler was generated by the Menu Builder. on menuPick pWhich --breakpoint switch pWhich case Cut --Insert script for Cut menu item here break case Copy set the clipboardData[Text] to the selectedText of the focusedObject break case Paste put clipboardData[text] into the focusedObject break case Clear put empty into the focusedObject break case Preferences --Insert script for Preferences menu item here break end switch end menuPick Do exactly the same as you did before. After you Paste and Tab or Clear and Tab LC will NOT Beep. I think the magic message you're looking for is just to use the standard LC commands that are available. When I create a menu like this it works as expected: --The following menuPick handler was generated by the Menu Builder. on menuPick pWhich switch pWhich case Cut cut break case Copy copy break case Paste paste break case Clear clear break case Preferences --Insert script for Preferences menu item here break end switch end menuPick -- Jacqueline Landman Gay | jac...@hyperactivesw.com HyperActive Software | http://www.hyperactivesw.com ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Scripting Cut/Copy/Paste in custom menus
On 9/14/2014, 11:19 PM, Kay C Lan wrote: Except Paul is right, on OS X the clear command in a custom built menu does not invoke a closeField message which it does if using the IDE's clear command. This does seem to be a bug. I never use clear so I had to look it up. Clear is a synonym of delete and only works on objects (delete this cd, delete img 1.) So that explains why it doesn't work in fields. I tried scripting a text deletion, but then we're back where we started -- scripted text changes don't trigger a closefield. So in the case of clear, your first solution is probably workable. I guess that explains why I always remove Clear from my menus. It's become so habitual, I'd forgotten why. -- Jacqueline Landman Gay | jac...@hyperactivesw.com HyperActive Software | http://www.hyperactivesw.com ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Scripting Cut/Copy/Paste in custom menus
On 9/14/2014, 11:19 PM, Kay C Lan wrote: Except Paul is right, on OS X the clear command in a custom built menu does not invoke a closeField message which it does if using the IDE's clear command. Forgot to mention: the IDE uses the delete command in it's Clear menu item script, but only applies it for objects. It scripts the deletion of text in fields, and that too fails to provide a closefield message. -- Jacqueline Landman Gay | jac...@hyperactivesw.com HyperActive Software | http://www.hyperactivesw.com ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Scripting Cut/Copy/Paste in custom menus
And you are correct Kay, in checking the target against the clipboard, after a busy day photographing dolphins I came back and tried another test. My original suggestion was too simple in that if the clipboardData contained an image it would paste the image over the top of everything on the card even though the target was a text field. My apologies for any confusion, I should have checked a few more options before posting instead of focussing too much on testing with text. Paul On Sep 14, 2014, at 9:19 PM, Kay C Lan lan.kc.macm...@gmail.com wrote: Except Paul is right, on OS X the clear command in a custom built menu does not invoke a closeField message which it does if using the IDE's clear command. This does seem to be a bug. On Mon, Sep 15, 2014 at 12:15 PM, J. Landman Gay jac...@hyperactivesw.com wrote: On 9/14/2014, 9:41 PM, Kay C Lan wrote: Now use the Menu Builder to create an OS X Menu for you, tick the box to Set as stack Menu Bar, have it auto build the script for you, and then open if for Edit and fill it as you would for Copy, Paste, and Clear. It should look something like this: --The following menuPick handler was generated by the Menu Builder. on menuPick pWhich --breakpoint switch pWhich case Cut --Insert script for Cut menu item here break case Copy set the clipboardData[Text] to the selectedText of the focusedObject break case Paste put clipboardData[text] into the focusedObject break case Clear put empty into the focusedObject break case Preferences --Insert script for Preferences menu item here break end switch end menuPick Do exactly the same as you did before. After you Paste and Tab or Clear and Tab LC will NOT Beep. I think the magic message you're looking for is just to use the standard LC commands that are available. When I create a menu like this it works as expected: --The following menuPick handler was generated by the Menu Builder. on menuPick pWhich switch pWhich case Cut cut break case Copy copy break case Paste paste break case Clear clear break case Preferences --Insert script for Preferences menu item here break end switch end menuPick -- Jacqueline Landman Gay | jac...@hyperactivesw.com HyperActive Software | http://www.hyperactivesw.com ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Scripting Cut/Copy/Paste in custom menus
I read from the Dictionary under closeField: The closeField message is not sent when a handler changes the field's contents using the put command.” May I submit that it ought to? An edited field is an edited field, and when it loses focus, if the contents are not what they were when it was opened, closeField *ought* to be sent! At any rate, I do not think there is a message I can send the the field to let it know the contents have changed. I am probably going to have to recode for textChanged. Bob S On Sep 13, 2014, at 17:55 , Bob Sneidar bobsnei...@iotecdigital.com wrote: Hi all. As many know, creating a custom menu set on OS X (not sure about Windows) will typically add the File and Edit menus to your customer menu set. This has the net effect of *disabling* cut/copy/paste/clear. I can live with that, because I have scripted the necessary menus to mimic the behaviors of those actions, but I am finding some quirks. First, if I cut or paste something in a field then tab out, closeField is not triggered. I assumed this was because the field was not getting selectionChanged, so I sent selectionChanged to the focusedObject after the cut/copy operations. Still, closeField does not get sent when I tab out of it. closeField DOES get sent if I simply edit the field then tab out. So what gets sent to the engine exactly that lets it know that the contents of a field have changed, so that tabbing out generates the proper closeField message? I suppose I could use textChanged to work around it, but frankly I would have to go through all my scripts which send a closeField to this object, and I’d rather not mess with what is already working. Bob S ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Scripting Cut/Copy/Paste in custom menus
Your suggestion, if it didn't break many stacks, would certainly slow them down. I mainly work with a Stack, a single card with anywhere between 10s to over a 100 fields, and a database. Going Next or Previous record populates those fields by using 'put' statements. Currently, even with 100+ fields it all happens in a blink of the eye. The user is then left to check the data, and if any are wrong those individual fields are changed, the closeField message is sent, which normally goes through some convoluted data verification process which includes not only checking the format of the data but also checking the MAX, MIN and UNIQUE entries in the database. Once all that is done the record is updated and everything is sweet. With what you are suggesting, every time I go Previous or Next the closeField message would be triggered 100+ times which is just a complete waste of time. The current logic of not triggering a closeField message has been with us since the birth of HyperCard. Frankly I wouldn't be surprised if you don't already have 1000s of situations across all your own stacks that already rely on this behaviour; the initial opening of your stack with all the fields prepopulated with data immediately comes to mind. From memory I handled your situation by setting a custom property in each field if data was pasted into it and then 'on exitField' testing to see if data had been pasted in: In the Edit Menu Script something like this: ... case Copy set the clipboardData[Text] to the selectedText of the focusedObject break case Paste put clipboardData[text] into the focusedObject set the cFldModByPaste of the focusedObject to true break ... and then in every fld script * something like this: on closeField --do what you need to here end closeField on exitField if (the cFldModByPaste of me = true) then --content change by paste so do closefield set the cFldModByPaste of me to false send closeField to me else --content hasn't been pasted in or changed end if end exitField * if groups of flds do exactly the same thing then you can save time by placing these scripts in a button and using behaviors. HTH On Sun, Sep 14, 2014 at 9:01 AM, Bob Sneidar bobsnei...@iotecdigital.com wrote: I read from the Dictionary under closeField: The closeField message is not sent when a handler changes the field's contents using the put command.” May I submit that it ought to? An edited field is an edited field, and when it loses focus, if the contents are not what they were when it was opened, closeField *ought* to be sent! At any rate, I do not think there is a message I can send the the field to let it know the contents have changed. I am probably going to have to recode for textChanged. Bob S On Sep 13, 2014, at 17:55 , Bob Sneidar bobsnei...@iotecdigital.com wrote: Hi all. As many know, creating a custom menu set on OS X (not sure about Windows) will typically add the File and Edit menus to your customer menu set. This has the net effect of *disabling* cut/copy/paste/clear. I can live with that, because I have scripted the necessary menus to mimic the behaviors of those actions, but I am finding some quirks. First, if I cut or paste something in a field then tab out, closeField is not triggered. I assumed this was because the field was not getting selectionChanged, so I sent selectionChanged to the focusedObject after the cut/copy operations. Still, closeField does not get sent when I tab out of it. closeField DOES get sent if I simply edit the field then tab out. So what gets sent to the engine exactly that lets it know that the contents of a field have changed, so that tabbing out generates the proper closeField message? I suppose I could use textChanged to work around it, but frankly I would have to go through all my scripts which send a closeField to this object, and I’d rather not mess with what is already working. Bob S ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Scripting Cut/Copy/Paste in custom menus
On 9/13/2014, 7:55 PM, Bob Sneidar wrote: As many know, creating a custom menu set on OS X (not sure about Windows) will typically add the File and Edit menus to your customer menu set. This has the net effect of*disabling* cut/copy/paste/clear. Not really. Did you use Menu Builder to set up the menu, and then click Auto-script? That inserts a menuPick handler with a switch statement all set up and ready to go, but without any specific commands. You have to add those yourself. If you don't, you have an empty menuPick that effectively blocks menu selections and keyboard shortcuts. Also make sure you set the menubar of the stack to the name of the menu group. I've not had any problems with menus as long as I do all that. If you have access to the RevLive conference videos, I covered a lot of this in my talk on menus. So what gets sent to the engine exactly that lets it know that the contents of a field have changed, so that tabbing out generates the proper closeField message? I agree with Kay that we don't want the engine sending closefields for us when scripts alter a field, and that's what textChanged is supposed to help with. But in this case I'd probably write the instructions into a separate handler, and then call that from the script that did the text alterations, and also from a closefield handler. That way either method will do the same thing. For example: on closeField doStuff end closeField And in some other handler somewhere: put xyz into fld 1 doStuff -- Jacqueline Landman Gay | jac...@hyperactivesw.com HyperActive Software | http://www.hyperactivesw.com ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode