New technique for disabling a Text Editor object

I just discovered a cool technique for temporarily disabling a Text Editor object. This technique uses a new feature in Panorama X 10.1. Suppose you have a fileglobal variable named DoNotEdit, and this variable can either be empty (editing is allowed) or contain “YES”, in which case editing is not allowed. Simply put this code in the Procedure panel of the Text Editor object.

return

startEditing:
    if DoNotEdit="YES"
        superobjectclose
        beep
    endif
    return

Now if the DoNotEdit variable is empty (or contains anything other than "YES"), you can click on the Text Editor object and edit the text inside. But if the DoNotEdit variable contains "YES", clicking on the object, or trying to type text into it, simply causes the computer to beep. Of course you don’t have to use a variable named DoNotEdit, you can use any formula that produces a true/false result.

To learn about the new feature that allows this, see the Multiple Trigger Options section of the Text Editor Object help page.

It would seem that you could follow the if statement with case statements that enable one to do things like decide who can edit the object.

Sure, you could have all sorts of logic depending on your needs – I was just presenting the most simple example I could think of that would illustrate the technique.