PolyGrid Direct Cell Editing?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
-
- Posts: 6
- Joined: Mon Feb 20, 2023 9:25 pm
PolyGrid Direct Cell Editing?
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!
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!
Re: PolyGrid Direct Cell Editing?
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...(?)OriginalPaladin wrote: ↑Fri Mar 03, 2023 8:28 pmI'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!
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.
Re: PolyGrid Direct Cell Editing?
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
Lance
Re: PolyGrid Direct Cell Editing?
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.
Re: PolyGrid Direct Cell Editing?
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!
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 88 times
-
- Posts: 6
- Joined: Mon Feb 20, 2023 9:25 pm
Re: PolyGrid Direct Cell Editing?
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...
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...
-
- VIP Livecode Opensource Backer
- Posts: 190
- Joined: Sat Apr 08, 2006 7:55 am
- Location: Lübbecke, Germany
- Contact:
Re: PolyGrid Direct Cell Editing?
You could post a feature request here https://quality.livecode.comIt just seems a bit misleading for LiveCode to post (in my (almost) link in the OP) "Direct cell editing" when there is none. Disappointing...
Especially regarding Polygrid and Polylist Livecode Ltd. was very quick with reasonable feature requests.
-
- VIP Livecode Opensource Backer
- Posts: 931
- Joined: Thu Nov 13, 2008 6:48 am
- Location: London, UK
Re: PolyGrid Direct Cell Editing?
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
Targets: Mac, iOS
-
- VIP Livecode Opensource Backer
- Posts: 264
- Joined: Sat Aug 16, 2008 9:48 am
- Location: Stockholm, Sweden
- Contact:
Re: PolyGrid Direct Cell Editing?
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.marksmithhfx wrote: ↑Tue Mar 28, 2023 8:12 pmIn your travels through the polygrid documentation have you found anything to set the column alignment in script? I have tried pgContentColumnAlignments with no success.
Andreas Bergendal
Independent app and system developer
Free LC dev tools: https://github.com/wheninspace
WhenInSpace: https://wheninspace.se/en
Independent app and system developer
Free LC dev tools: https://github.com/wheninspace
WhenInSpace: https://wheninspace.se/en
Re: PolyGrid Direct Cell Editing?
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
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
-
- VIP Livecode Opensource Backer
- Posts: 264
- Joined: Sat Aug 16, 2008 9:48 am
- Location: Stockholm, Sweden
- Contact:
Re: PolyGrid Direct Cell Editing?
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.
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
Free LC dev tools: https://github.com/wheninspace
WhenInSpace: https://wheninspace.se/en
Independent app and system developer
Free LC dev tools: https://github.com/wheninspace
WhenInSpace: https://wheninspace.se/en
-
- VIP Livecode Opensource Backer
- Posts: 931
- Joined: Thu Nov 13, 2008 6:48 am
- Location: London, UK
Re: PolyGrid Direct Cell Editing?
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.Lance wrote: ↑Tue Mar 28, 2023 9:36 pmI 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
Mark
macOS 12.6.5 (Monterey), Xcode 14.2, LC 10.0.0, iOS 15.6.1
Targets: Mac, iOS
Targets: Mac, iOS
Re: PolyGrid Direct Cell Editing?
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
thanks
Lance
- Attachments
-
- PolyGridTest.zip
- (1.66 KiB) Downloaded 29 times
-
- VIP Livecode Opensource Backer
- Posts: 4016
- Joined: Sun Jan 07, 2007 9:12 pm
- Location: Bochum, Germany
Re: PolyGrid Direct Cell Editing?
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"
Please feel free to use it if you want to.
Kind regards
Bernd
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
Kind regards
Bernd
Re: PolyGrid Direct Cell Editing?
Bernd, nice improvement. Thanks for sharing.
Lance
Lance