Hi Ray,

When the script editor opens, the message seem to be locked. I tried to trigger the preOpenStack message when the script editor opens in MetaCard and that works perfectly. Apparently, the creator of the LiveCode script editor doesn't want us to intercept messages while editing a script in LiveCode.

However, you can use the editScript message. "Unfortunately", this message is sent to the control whose script is being edited and not to the script editor. (I write "unfortunately" in quotes, because it is still expected behaviour and necessary for the script editor to work).

In the editScript message, you can loop through all stacks that contain "revScriptEditor" in their short name and check that they are on screen. Here's an example:

constant lPreferredRect ="-1157,-111,-180,644"
local lScriptEditorIsOpen

on checkScriptEditorLocs
   if lScriptEditorIsOpen is not true then
      if there is a stack "revNewScriptEditor 1" then
         set the rect of stack "revNewScriptEditor 1" to lPreferredRect
         put true into lScriptEditorIsOpen
      end if
   end if
   repeat for each line myStack in the windows
      if myStack contains "revNewScriptEditor" then
         put false into myVis
         repeat for each line myRect in the screenRects
            if there is a stack myStack then
               if the topleft of stack myStack is within myRect or \
                  the topRight of stack myStack is within myRect or \
                  the bottomLeft of stack myStack is within myRect \
                  or the bottomRight of stack myStack is within \
                    myRect then
                  put true into myVis
                  exit repeat
               end if
            end if
         end repeat
         if myVis is false and there is a stack myStack then
            set the loc of window myStack to the screenLoc
         end if
      end if
   end repeat
end checkScriptEditorLocs

on editScript
   put ("revNewScriptEditor" is in the openStacks) into \
      lScriptEditorIsOpen
   send "checkScriptEditorLocs" to me in 0 milliseconds
   pass editScript
end editScript

Make sure that this script is in a front script.

The funny thing is that while testing the script editor, I seem to have broken it. Its default behaviour now is to open on my primary screen. Therefore, I have added a little feature, which opens it on my secondary screen, if no script editor is open yet. For me, this is useful, because I edit all scripts in one window. Change the constant at the top of the script to set the location where you want your script editor to open. Let me know if you encounter any problems when trying this script.

--
Best regards,

Mark Schonewille

Economy-x-Talk Consulting and Software Engineering
Homepage: http://economy-x-talk.com
Twitter: http://twitter.com/xtalkprogrammer
KvK: 50277553

Use Color Converter to convert CMYK, RGB, RAL, XYZ, H.Lab and other colour spaces. http://www.color-converter.com

Buy my new book "Programming LiveCode for the Real Beginner" http://qery.us/3fi

LiveCode on Facebook:
https://www.facebook.com/groups/runrev/

On 1/30/2014 18:25, Ray wrote:
Let me know how it goes Mark.  I'd like to get a little more feedback
before writing a bug report.

On 1/30/2014 12:18 PM, Mark Schonewille wrote:
Ray, I'll try it myself, later tonight.


--
Best regards,

Mark Schonewille

Economy-x-Talk Consulting and Software Engineering
Homepage: http://economy-x-talk.com
Twitter: http://twitter.com/xtalkprogrammer
KvK: 50277553

Use Color Converter to convert CMYK, RGB, RAL, XYZ, H.Lab and other
colour spaces. http://www.color-converter.com

Buy my new book "Programming LiveCode for the Real Beginner"
http://qery.us/3fi

LiveCode on Facebook:
https://www.facebook.com/groups/runrev/

On 1/30/2014 16:26, Ray wrote:
I'm not having any luck with inserting the following script into front:

on preOpenStack
    put the ticks
end preOpenStack

With this inserted I get a message box opened with the ticks when I open
another stack from the desktop, but no ticks when I shift-control-S to
open the stack script (the script editor window).  Evidently a script
inserted into the front doesn't get triggered when opening the script
editor.  Neither does the 'start using stack' method.

Am I doing this right?

Ray


_______________________________________________
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

Reply via email to