This is weird.
I wrote a procedure to trap a mouse click on a text list object, check if it an option-click and, if so, create a temporary text editor object on top of the clicked cell to allow it to be edited in place:
fileglobal CellRectangle
let ClickPosition=info("click")
let X=info("matrixcolumn")
let Y=info("matrixrow")
if optionclick()
objectaction "ThisList","CellRectangle",Y,X,CellRectangle
CellRectangle=rectangleadjust(xytoxy(CellRectangle,"w","f"),-2,-5,2,5)
newformobject "RectangleShapeObject",
"color",htmlrgb("ffeeaa"),
"rectangle",CellRectangle
newformobject "TextEditorObject",
"$BorderBottomMargin","2 px",
"$BorderTopMargin","2 px",
"$TextEditorBorderStyle","Bezel",
"$TextEditorDontWrap","1",
"$TextEditorFocusRing","0",
"$TextEditorTerminateReturn","1",
"$TextEditorTerminateTab","1",
"$TextEditorTerminateUpDown","1",
"$TextEditorTriggerFinished","1",
"$TextEditorUpdateVariableEveryKey","1",
"FieldName","ThisTrackTitle",
"Procedure","call TrackEditingDone",
"rectangle",CellRectangle
// (etc.)
(call TrackEditingDone
later deletes the text editor object as soon as editing is terminated, and writes the variable to the database cell.)
This all worked perfectly — until I tried it with a long scrolling text list. It still works fine near the top of the list, but as soon as it’s scrolled, option-clicking on a cell no longer caused the text editor object to appear.
Investigating further, it appears that once the text list is scrolled, the cell rectangle returned by the objectaction
statement has negative co-ordinates.
The cell rectangle is returned in window-relative co-ordinates and the mouse click in screen-relative co-ordinates, but when I insert this line after the objectaction
command to compare the two in the same co-ordinate system:
message "CellRectangle (window to screen):"+¶+"Top: "+rtop(xytoxy(CellRectangle,"w","s"))+¶+"Bottom: "+rbottom(xytoxy(CellRectangle,"w","s"))+¶+¶+"Mouse (screen): y="+v(ClickPosition)
if I click on one of the first few rows in the text list when it’s not scrolled I get this credible result, showing that the mouse click lay between the top and bottom of the reported co-ordinates of the 22px-high cell (the row height for my text list):
but if I scroll the list down to the middle and click on, for instance, the 70th cell out of 300, this is the result:
So (a) it is no longer correctly reported as a 22px-high rectangle (top and bottom y-co-ordinates are equal) and (b) the y-co-ordinates are negative — thus my text editor object was created off-screen.
Has anyone else noticed this?
(Panorama X 10.2.0.b33 (4268), macOS 13.4.1, M1 Max)