I updated my modifications to the script of widget "myPolyGrid" taking account of the font used in widget "myPolyGrid" and also fine-tuned the placement of the topMargin to fit better in a wider range of rowHeight and textSize combinations of the widget.
Here is the updated script
Code: Select all
on cellClick pColumnNumber, pRowNumber, pCellRect
--put the pCellRect into tCellRect
set the pgInternalPointer of widget "myPolyGrid" to pRowNumber
put the pgDataOfRow of widget "myPolyGrid" into tDataA
put tDataA["col " & pColumnNumber] into tCellData
## show the cell content to the user to correct/replace it
put tCellData into field "UserEdit"
## show data at approximately where is is in the cell of polygrid
set the textSize of field "UserEdit" to the textSize of widget "myPolyGrid"
set the textAlign of field "UserEdit" to "center"
set the textFont of field "UserEdit" to the effective textFont of widget "myPolyGrid"
## adjust vertical placement of text in field "UserEdit"
put the rowHeight of widget "myPolyGrid" into tHeight
put item 2 of (measureText(tCellData,field "UserEdit", size)) into tMeasureHeight
put tHeight - tMeasureHeight into tHeightDiff
put max((tHeightDiff - tHeightDiff/3),8) into tTopMargin
put the ceiling of tTopMargin into tTopMargin
set the topMargin of field "UserEdit" to tTopMargin
set the cColumn of me to pColumnNumber -- save column number to custom property
set the cRow of me to pRowNumber -- save row number to custom property
set the rect of field "UserEdit" to pCellRect -- get the rect of the cell clicked
set the visible of field "UserEdit" to true
--Send user to the field for possible updates
focus on field "UserEdit"
end cellClick
Thanks in advance.
Kind regards
Bernd