ObjectAction error

When running procedures that include some object action, even if the appropriate form is open and foremost in Panorama, if another app is active, such as TextEdit, an error occurs. An error message declares “ObjectAction statement can only be used in a form window”.

Bracket your objectaction statement between magicformwindow and magicwindow statements. This will allow it to function when the form is not the active window.

Does this work? My answer was going to be that it couldn’t be done.

I find it works to scroll a Text List Object while in the background behind another application as well as using changeobject to move things on the form in the background.

So what do you mean by “bracket … between”?

Poor choice of terminology I guess. I just mean that the procedure should first have a magicformwindow “MyForm” statement before the objectaction statement followed by a magicwindow “” statement if needed.

Thanks Gary. It took me a while to respond because I’ve been trying to find a way to implement the suggestion. It seemed like the most likely place to put it was at the start of the procedure. Then if the window wasn’t the active window by the time the ObjectAction came up, it should work.

The problem from the start though is even when the targeted form is and remains the active form, all I have to do is activate any other app; TextEdit, Finder… and I get the error. Panorama requires that I don’t touch anything before the procedure gets to that point.

Otherwise it’s the following error plus dimmed menus that suggest a procedure is still running.
Screen Shot 2022-08-23 at 8.54.00 AM

The offending line is to redraw a display matrix:

SuperObject “MemRanks”,“redraw”,“all”,0,0

I made a simple matrix named MemRanks like yours, set to formula and my field A which had a list of records with the names of current windows. I made a procedure to start a timer that is run in the background and initially delayed for 5 seconds to allow me to go to another application before execution. It runs only once and calls a second procedure with this code:

magicformwindow "Untitled","Test"
objectaction “MemRanks”,“redraw”,“all”,0,0
magicwindow ""

While in another application like Mail (Terminal and Console as well) the timer runs and triggers this code so that the matrix redraws. Until I added the noshow and showpage/endnoshow statements it did not redraw. It then finally worked using either the objectaction or superobject statement. It also worked when the other application was on my second monitor or on my main monitor. Tested using b27 (4102) on my M1 iMac running Monterey 12.4

Note: Further experimenting showed I only needed the showpage statement for it to redraw (no need for the noshow/endnoshow statements).

Thanks Gary. It is working.

As it turns out, a subsequently called procedure had a similar situation so when I fixed the first, the error continued to show up. So by moving magicwindow “” to the very end of the procedure, it works and heads off all such errors.

The file has quite a few matrices so I’m starting and ending a number of the procedures with magicformwindow and magicwindow.

BTW, the reason I had SuperObject is that this is one of several procedures ported from Pan 6 and I haven’t yet pursued updates that don’t matter at the moment.