Text Editor Object


#1

I have a datasheet with only one field. Call it colors. I enter a color, hit return which adds a record. Enter another color, hit return, etc. Is there a way to duplicate this exact behavior on a form using a single Text Editor object? I found the info on .NewRecord but haven’t figured out how to make that work, and the number of Text Editor options has me tied in knots.

thanks
bk


#2

If you name your TEO “myTEO” you can put this code in the Code tab of Properties panel:

If Color<>""
    addrecord
    Color=""
    objectaction "myTEO","Open"
Endif

Have all the Termination Keys checked and Set the Procedure Trigger to End Editing in the Options panel.


#3

Once again I doff my cap. I had never heard of objectaction (or its Pan 6 ancestor), nor did I suspect that TEOs could be ‘named’.

thanks again, again
bk


#4

This thread seems like a good place to remind folks about a new option in Panorama X 10.1 that you may have missed. You can now have code that handles multiple Text Editor trigger events, so for example you can have one set of custom code that runs when you start editing, and another when you finish editing. This wasn’t possible before.

finishEditing:
    if Color<>""
        addrecord
        Color=""
        objectaction "myTEO","Open"
    endif

If your code includes these labels (finishEditing:, startEditing: etc.), it is not necessary to check the Procedure Trigger enable options in the property panel. You can leave these unchecked, but Panorama will still trigger the code if the label is there (it will also trigger the code if these options are checked, basically the labels override the checkboxes).

One other tip – you don’t actually have to give the object a name for this application (it won’t hurt anything if you do, but it’s not necessary). Instead, you can use the `info(“clickedobjectid”) function to get the id of the object that was just being edited, like this:

objectaction info("clickedobjectid"),"open"

This would be especially handy if you were using this code in a subroutine where it might be called from different Text Editor objects at different times.


#5

Does this mean it might be possible to combine your finishEditing example with another bit of code that would pre-pend the contents of a variable?

Say I want the word “dark” to be added to each color that I enter, so:

fileglobal theColorModifier
the colorModifier=“dark”

How would I add this to the finishEditing code so that every color I enter has “dark” or a different modifier prepended?


#6

Sure, you can add whatever code you want. That was always true. What is different is that now you can perform different actions when the editor opens, when it closes, and when a key is pressed. In previous versions, it would perform the same code no matter what event had happened,

I forgot to include a link to the documentation. Look for Multiple Trigger Options on this page.