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

OriginalPaladin
Posts: 6
Joined: Mon Feb 20, 2023 9:25 pm

PolyGrid Direct Cell Editing?

Post by OriginalPaladin » Fri Mar 03, 2023 8:28 pm

Hello,

I've purchased the PolyGrid widget, but find that any documentation on it is scarce at best. Any know how to do the Direct Cell Editing as listed at livecode dot com /polygrid-widget-in-the-spotlight/ in #9? Thanks!

stam
Posts: 2683
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: PolyGrid Direct Cell Editing?

Post by stam » Sun Mar 05, 2023 3:57 am

OriginalPaladin wrote:
Fri Mar 03, 2023 8:28 pm
I've purchased the PolyGrid widget, but find that any documentation on it is scarce at best. Any know how to do the Direct Cell Editing as listed at livecode dot com /polygrid-widget-in-the-spotlight/ in #9? Thanks!
I might be wrong (and happy to be corrected!) but I don't think there is 'direct editing' in polygrid if you mean inline editing...(?)

But you can edit the row data directly with either setting the pgDataOfRow, pgHilitedData or to edit the pgData of the widget (look at the dictionary for these). Just be aware that that before setting pgDataOfRow, you need to set the widget's property pgInternalPointer to the desired row first. However none of these will specifically edit cell data, but rather row data.

But nowhere have I come across inline editing - instead on cellClick (or cellDoubleClick) I put the data into an object of some kind, and then update the polygrid with one of the above. But happy to be corrected if there's a better way!

S.

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

Re: PolyGrid Direct Cell Editing?

Post by Lance » Sun Mar 05, 2023 1:49 pm

I created a sample stack for myself a bit ago that allows you to click on a cell and a popup box allows you to enter a new value for the cell. Works pretty well and was just to help me understand the PolyGrid better. For whatever reason i am not able to attach a file so if you would like the sample stack just shoot me an email at lcrosby at nsales dot com , be happy to share it. (not allowed to post email addresses either i guess)

Lance

stam
Posts: 2683
Joined: Sun Jun 04, 2006 9:39 pm
Location: London, UK

Re: PolyGrid Direct Cell Editing?

Post by stam » Sun Mar 05, 2023 2:56 pm

Lance wrote:
Sun Mar 05, 2023 1:49 pm
For whatever reason i am not able to attach a file
Thanks Lance,
generally the forum will accept files up to 200 Kb but they need to be zipped - you can't just upload an unzipped stack.
If your stack is truly larger than that and is of potential general help you could also consider uploading it to Sample Stacks...

S.

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

Re: PolyGrid Direct Cell Editing?

Post by Lance » Sun Mar 05, 2023 3:01 pm

Hello Stam,

I was not aware it had to be a zip file. I am attaching the sample i built. Hope it is helpful.

thanks!
Attachments
poly grid.zip
(4.23 KiB) Downloaded 83 times

OriginalPaladin
Posts: 6
Joined: Mon Feb 20, 2023 9:25 pm

Re: PolyGrid Direct Cell Editing?

Post by OriginalPaladin » Mon Mar 06, 2023 7:15 pm

Thanks Lance,

that's definitely better than nothing. It just seems a bit misleading for LiveCode to post (in my (almost) link in the OP) "Direct cell editing" when there is none. Disappointing...

matthiasr
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 190
Joined: Sat Apr 08, 2006 7:55 am
Location: Lübbecke, Germany
Contact:

Re: PolyGrid Direct Cell Editing?

Post by matthiasr » Mon Mar 06, 2023 8:10 pm

It just seems a bit misleading for LiveCode to post (in my (almost) link in the OP) "Direct cell editing" when there is none. Disappointing...
You could post a feature request here https://quality.livecode.com

Especially regarding Polygrid and Polylist Livecode Ltd. was very quick with reasonable feature requests.

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am
Location: London, UK

Re: PolyGrid Direct Cell Editing?

Post by marksmithhfx » Tue Mar 28, 2023 8:12 pm

Lance wrote:
Sun Mar 05, 2023 3:01 pm
Hello Stam,

I was not aware it had to be a zip file. I am attaching the sample i built. Hope it is helpful.

thanks!
Nice demo stack Lance. In your travels through the polygrid documentation have you found anything to set the column alignment in script? I have tried pgContentColumnAlignments with no success.

Mark
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

SWEdeAndy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 261
Joined: Sat Aug 16, 2008 9:48 am
Location: Stockholm, Sweden
Contact:

Re: PolyGrid Direct Cell Editing?

Post by SWEdeAndy » Tue Mar 28, 2023 9:11 pm

marksmithhfx wrote:
Tue Mar 28, 2023 8:12 pm
In your travels through the polygrid documentation have you found anything to set the column alignment in script? I have tried pgContentColumnAlignments with no success.
Mark, search for pgColumns in the docs. It's an array that holds many properties of the polyGrid layout, with columnIndex["contentAligment"] being the one of particular interest here.
Andreas Bergendal
Independent app and system developer
WhenInSpace: https://wheninspace.se

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

Re: PolyGrid Direct Cell Editing?

Post by Lance » Tue Mar 28, 2023 9:36 pm

I had not tried this and Andreas is correct, i tried this and while maybe there is a more direct way, it worked.

put the pgColumns of widget "PolyGrid1" into tArray
put "left" into tArray["3"]["ContentAlignment"]
set the pgColumns of widget "PolyGrid1" to tArray

thanks Andreas, and thanks Mark for the kind comment.

Lance

SWEdeAndy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 261
Joined: Sat Aug 16, 2008 9:48 am
Location: Stockholm, Sweden
Contact:

Re: PolyGrid Direct Cell Editing?

Post by SWEdeAndy » Wed Mar 29, 2023 7:38 am

Lance, that's a good code example, it's how I do it too. I don't think there's a more direct way.

Also, good catch on the typo - I copied ["contentAligment"] (sic!) straight from the docs, but one must naturally spell it ["contentAlignment"] to make it work. :)
Andreas Bergendal
Independent app and system developer
WhenInSpace: https://wheninspace.se

marksmithhfx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 931
Joined: Thu Nov 13, 2008 6:48 am
Location: London, UK

Re: PolyGrid Direct Cell Editing?

Post by marksmithhfx » Wed Mar 29, 2023 9:04 am

Lance wrote:
Tue Mar 28, 2023 9:36 pm
I had not tried this and Andreas is correct, i tried this and while maybe there is a more direct way, it worked.

put the pgColumns of widget "PolyGrid1" into tArray
put "left" into tArray["3"]["ContentAlignment"]
set the pgColumns of widget "PolyGrid1" to tArray

thanks Andreas, and thanks Mark for the kind comment.

Lance
Thanks guys, and for the example Lance... very helpful! From the provided documentation there really isn't enough information to know how to process that property without a little experimentation.

Mark
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS

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

Re: PolyGrid Direct Cell Editing?

Post by Lance » Tue Apr 16, 2024 2:06 pm

So I had put PolyGrid in the closet for some time and decided to take another look at using it more as it is so fast. I went back to direct cell editing and have a very simple sample where if you click on a cell a field is sized the same as the cell and allows you to update the cell content. Works pretty well and has what i think is a clean user feel for it. I feel it is an improvement over my prior sample posted. So thought I would share the sample.

thanks
Lance
Attachments
PolyGridTest.zip
(1.66 KiB) Downloaded 10 times

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 » Tue Apr 16, 2024 4:42 pm

Hi Lance,

Thank you for posting this. It solves a major problem with the PolyGrid.

I took the liberty to extend your code:
1. I wanted to see the current text of the cell of the polyGrid in field "UserEdit" since often one just wants to correct a typo etc.
2. I wanted the text in field "UserEdit" to appear at approximately the same place where it is placed in the cell of the widget

This is the amended code for the script of widget "myPolyGrid"

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
   set the textSize of field "UserEdit" to the textSize of widget "myPolyGrid"
   set the textAlign of field "UserEdit" to "center"
   
   ## 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) - tMeasureHeight/3 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
Please feel free to use it if you want to.

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 » Tue Apr 16, 2024 5:10 pm

Bernd, nice improvement. Thanks for sharing.

Lance

Post Reply

Return to “Talking LiveCode”