PolyList and variable itemHeight to fit text in an item

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
tomsve
Posts: 45
Joined: Tue Jan 20, 2015 5:01 pm
Location: Ukraine/Armenia

PolyList and variable itemHeight to fit text in an item

Post by tomsve » Sun Apr 16, 2023 9:28 pm

I'm trying to use itemPointer to change the itemHeight of an individual item in the PolyList, so it can fit the text in it (they all have a text . However, it seems to change all of the items in the list, not the individual item.

This is the code I use for testing.

Code: Select all

   set the itemPointer of widget "plList" to 1
   set the itemHeight of widget "plList" to 100
Is it even possible? Any ideas?

Thanks and regards.

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

Re: PolyList and variable itemHeight to fit text in an item

Post by SWEdeAndy » Mon Apr 17, 2023 7:41 am

tomsve wrote:
Sun Apr 16, 2023 9:28 pm
Is it even possible?
No, unfortunately not, as far as I know. The PolyList and PolyGrid don't have variable item/row height yet. I think there's an enhancement request in for that. You'll have to use the good old datagrid to get variable row height.
Andreas Bergendal
Independent app and system developer
WhenInSpace: https://wheninspace.se

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

Re: PolyList and variable itemHeight to fit text in an item

Post by stam » Mon Apr 17, 2023 10:06 am

SWEdeAndy wrote:
Mon Apr 17, 2023 7:41 am
tomsve wrote:
Sun Apr 16, 2023 9:28 pm
Is it even possible?
No, unfortunately not, as far as I know. The PolyList and PolyGrid don't have variable item/row height yet. I think there's an enhancement request in for that. You'll have to use the good old datagrid to get variable row height.
There is much that the venerable DataGrid2 does much better than the newcomers - I just wish it was better encapsulated like PoyList and PolyGrid are, and had the clever multi-column facility of PolyList.

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

Re: PolyList and variable itemHeight to fit text in an item

Post by bn » Mon Apr 17, 2023 3:29 pm

Hi Tom,

If all you want is to fit more text into e.g. the top item then you can tweak the Polygrid to show more text without changing the overall appearence too much.

Assume you drag out a new Polylist in the IDE (I am using 9.6.9) and you want to change text in "Title" to accomodate more text than currently fits.
You could change "Title" to multiline and change its height and position.
This affects all items of the polygrid but barely shows.

Use this script to apply the necessary changes(I did not find an easier way)

Code: Select all

on mouseUp
   local tDataLayoutA, tItemContentA
   
   ## change top text item "Title" of standard widget "Polylist" as in IDE (9.6.9)
   
   put the dataLayout of widget 1 into tDataLayoutA
   put 0 into tDataLayoutA[2]["top"]
   put 60 into tDataLayoutA[2]["height"]
   put "text-multiline" into tDataLayoutA[2]["content-type"]
   set the dataLayout of widget 1 to tDataLayoutA
   
   ## change text of first item and set text of "Title"
   set the itemPointer of widget"PolyList" to 1
   put the itemContent of widget"PolyList" into tItemContentA
   
   put "New content" & cr & "new line is much longer than fits" into tItemContentA["title"] ## with cr
   -- put "New content new line is much longer than fits" into tItemContentA["title"] ## auto wrap
   set the itemContent of widget"PolyList" to tItemContentA
   
   ## increase itemHeight slightly to make room for multiline text
   set the itemHeight of widget"PolyList" to 50
end mouseUp
It looks a bit intimidating but that seems to work for small tweaks. (DataGrid is also not the easiest to tweak)

But maybe that is not what you are after then it was a nice exercise in configuring a Polygrid.

Kind regards
Bernd

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

Re: PolyList and variable itemHeight to fit text in an item

Post by bn » Mon Apr 17, 2023 9:11 pm

Hi Tom,

I had a look at the Polygrid using the Properties Inspector. You can set all the paramters I've set via script manually using the Properties Inspector.

Kind regards
Bernd

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

Re: PolyList and variable itemHeight to fit text in an item

Post by marksmithhfx » Tue May 02, 2023 12:04 pm

SWEdeAndy wrote:
Mon Apr 17, 2023 7:41 am
that. You'll have to use the good old datagrid to get variable row height.
Andreas, do you happen to know of a code example that demonstrates how to get variable row height in the data grid? I've been wanting to add that to my Organize app for eons but just didn't know it was possible.

Thanks
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: 257
Joined: Sat Aug 16, 2008 9:48 am
Location: Stockholm, Sweden
Contact:

Re: PolyList and variable itemHeight to fit text in an item

Post by SWEdeAndy » Tue May 02, 2023 12:45 pm

marksmithhfx wrote:
Tue May 02, 2023 12:04 pm
Andreas, do you happen to know of a code example that demonstrates how to get variable row height in the data grid? I've been wanting to add that to my Organize app for eons but just didn't know it was possible.
I seem to remember using a LiveCode lesson on how to make a messenger-type app as a basis, when I needed to make a messenger-type feature once, but I can't find that one now.

But I found this one that might even better suit your needs:
https://lessons.livecode.com/m/datagrid ... ne-heights
(how-do-i-create-a-form-with-variable-line-heights)
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: PolyList and variable itemHeight to fit text in an item

Post by marksmithhfx » Tue May 02, 2023 12:51 pm

SWEdeAndy wrote:
Tue May 02, 2023 12:45 pm
But I found this one that might even better suit your needs:
https://lessons.livecode.com/m/datagrid ... ne-heights
(how-do-i-create-a-form-with-variable-line-heights)
Thanks Andreas for reminding me about this one :oops: I posted about it in the message section of the lesson back in 2020 but never got around to trying it... where does the time fly? (However my procrastination may have a benefit as Elanor added a modification in 2021 which she said may make the process clearer. I hope!!)

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

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”