PolyGrid Direct Cell Editing?

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4003
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: PolyGrid Direct Cell Editing?

Post by bn » Wed Apr 17, 2024 8:01 pm

Lance,

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
If you are done with this it may be a useful if you post again a sample stack with your final version.
Thanks in advance.

Kind regards
Bernd

Lance
Posts: 23
Joined: Sat Sep 05, 2020 2:36 pm
Location: Anchorage, Alaska

Re: PolyGrid Direct Cell Editing?

Post by Lance » Wed Apr 17, 2024 10:47 pm

Hello Bernd,

Your improvements keep coming. Put your updates into the sample and worked great. Attaching an updated zip file with 'our' work:).

Cheers.
Attachments
PolyGridTest.zip
(1.84 KiB) Downloaded 10 times

Post Reply

Return to “Talking LiveCode”