Changeobject in .currentrecord Procedure

I have a database that I use to transform the rules of my Mail.app from XML to a table format. A form displays all the information including color information (e.g. you have rules mark messages in the message list with a coloured background). I managed to display the color information with a coloured rectangle by using a changeobject statement in a .currentrecord procedure. This was working flawlessly in Pan X 10.1.

Yesterday I recognised that this “ColorSample” display did not work anymore in Pan X 10.2 b16. No color was displayed. I can’t tell with which version this started. I tried several workarounds to get it back to work — including showpage or showrectangle statements —, but without success.

Accidentally I noticed that the desired colour was displayed immediately whenever I went into Graphic Mode and modified width or height of the “ColorSample” object.

So I added a size modification to my .currentrecord procedure:

changeobject "ColorSample", "Color", ?(Color="","FFFFFF",hexstr(val(Color))[-6,-1])
changeobject "ColorSample", "rectangle",rectangleadjust(objectinfo("rectangle"),0, 0, 72, 72)
changeobject "ColorSample", "rectangle",rectangleadjust(objectinfo("rectangle"),0, 0, -72, -72)

With this workaround the object gets refreshed immediately — in fact, so quickly that I am not able to watch the size change at all. Now my color display is working as expected again.

Bildschirmaufnahme (PanoramaX)

I’m wondering if it wouldn’t be better to use an Image Display Object in this case with a formula of "%%"+Color and a showvariables Color as part of your .CurrentRecord procedure. In my simple testing I could not get the ColorSample rectangle object to not refresh using a changeobject command in the .CurrentRecord procedure. This was using the same beta version so I don’t know what the difference might be except you must have a more complex procedure involved.

You might also try using showother «»,99 to force your rectangle object to update. This statement has sometimes made items refresh that nothing else seemed to be able to accomplish.

Gary, I tried it and am using this function for the Image Display object:

"%%"+hexstr(val(Color))[-6,-1]

I can only get it to work if I use the same resize trick in my .currentrecord procedure, but so I am saving the changeobject “Color” line.

Well, are we using the same MacOS version, too? I am using Big Sur 11.4.

No, I’m stuck on 10.13.6 High Sierra and that could be the problem. You might have the same result using Panorama X 10.1 if you have upgraded your systems since you last tried it.

I wonder if this could be related to the problem that causes the data sheet cursor to not update when switching fields in Big Sur.

This would be my suggestion also. I’m also thinking that Color is a field, not a variable, in which case no code should be needed at all, just a formula in the Image Display object of:

"%%"+?(Color="","FFFFFF",hexstr(val(Color))[-6,-1]

That’s exactly what I did finally, because there were some records where the Color field is empty.

I thought this would be enough to display the color without any .currentrecord procedure, but I need my size change trick to make the color show.

I just tried using an Image Display object on an macOS 11.4 system, and it worked perfectly. No .CurrentRecord needed, no size change trick required.

Jim, I made a test and exported just the “Color” column into a new database. Then I created a form with an Image Display object with the mentioned formula.
Now the Image Display object is working now as expected without any .CurrentRecord — but only when the form window is active.
Pan X Color Display
But in my “Mail Rules” database, where the form is the only open window anyway, the color display still needs the .CurrenRecord procedure with the resize trick.

Now it seems the cause is located in my database only, not in my installed PanX version / macOS version / third party software conflicts.