Table field and listStyle

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

stam
Posts: 3072
Joined: Sun Jun 04, 2006 9:39 pm

Table field and listStyle

Post by stam » Fri Nov 27, 2020 12:33 pm

Hi all,
i need an extremely basic list and for all intents and purposes a simple table field ought to suffice.
Ideally each line should be prefixed with a number so it appears to be a numbered list (although the text is stored in a database as a single field).

Rather than coding my own number listing for each line (which is what i've done in other environments), i thought i'd try the setting the "listStyle" property.

Code: Select all

set the listStyle of line 1 to -1 of field "table field" to "decimal"
So far so good - it produces a neatly laid out list...

But if i want to edit this as a user and just click into the field in browse mode, the text instantly morphs irreversibly into HTML text making it almost unreadable:
Image

Surely this isn't expected behaviour?
Or will I have to lock the text and store the editable version of the text in a custom property and provide the user another way to edit this? (keeping in mind i'm very lazy...)

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10048
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Table field and listStyle

Post by FourthWorld » Fri Nov 27, 2020 4:09 pm

Do you have a recipe by which we can reproduce that, or a sample stack illustrating the issue we can look at?

I've not seen any case where the htmltext of a field is displayed in that field without explicitly requesting it. We'll solve it, we just need to see it.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Table field and listStyle

Post by Klaus » Fri Nov 27, 2020 4:34 pm

Richard,

simply create a table field, add some lines and apply stams script. 8)
Then doubleclick on an entry and see what happens!

Just tested in LC 9.6.1 and can confirm this, what I consider a bug.
Obviously "table fields" and any set HTMLTEXT don't go well together.


Best

Klaus

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10048
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Table field and listStyle

Post by FourthWorld » Fri Nov 27, 2020 5:31 pm

Klaus wrote:
Fri Nov 27, 2020 4:34 pm
Richard,

simply create a table field, add some lines and apply stams script. 8)
Then doubleclick on an entry and see what happens!
I look forward to doing that when I return to my computer. Thanks for confirming.
Just tested in LC 9.6.1 and can confirm this, what I consider a bug.
Obviously "table fields" and any set HTMLTEXT don't go well together.
Maybe I missed something: where is he setting htmltext?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: Table field and listStyle

Post by dunbarx » Fri Nov 27, 2020 6:03 pm

I am not understanding.

Are you saying there is no line of code anywhere in the field, card or stack, whatever, that explicitly sets the htmlText?

You do not get the "phantom" editable field in the "cell" you clicked on? That the line clicked on simply changes to the htmlText of that line? Or does the entirety of the field change with a single click?

Craig

Klaus
Posts: 14194
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Table field and listStyle

Post by Klaus » Fri Nov 27, 2020 6:17 pm

FourthWorld wrote:
Fri Nov 27, 2020 5:31 pm
Maybe I missed something: where is he setting htmltext?
Not explicitly, but what we see in the field in the end is some sort of html, isn't it? 8)
See the right side of the image that stam posted.
Try my recipe and you will see yourself.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10048
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Table field and listStyle

Post by FourthWorld » Fri Nov 27, 2020 6:49 pm

So the problem isn't with setting htmltext per se (which is important, because that's a valuable feature), but in this case the table field script is apparently setting the text to the htmltext, which would be a bug.

Anyone know offhand if this has been reported before?
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7391
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Table field and listStyle

Post by jacque » Fri Nov 27, 2020 8:16 pm

Do you actually need a table field? If the content doesn't rely on tab-delimited data where the user can edit individual items then a regular field should work without the html glitch.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

stam
Posts: 3072
Joined: Sun Jun 04, 2006 9:39 pm

Re: Table field and listStyle

Post by stam » Fri Nov 27, 2020 10:19 pm

Thanks everyone,
this was a surprise discovery in the short time i had before having to go to work and i've not had chance to consider this again before now.

@jaque - strictly speaking i don't need a anything more complex than a simple text field - but having this as a table field gives the user the illusion of editing a row rather than flowing text, which is the desired effect. i'm using liveCode to produce a better version of my previous app (i've implemented this in XOJO and Filemaker Pro previously) - and better user experience as well. And i'm posting this here because it looks like a bug to me...

@craig - no i'm not modifying htmltext at all. I literally just run the code above in the message box. I all looked good until i actually just clicked into the field and you can see what happened above.

@richard - happy to upload a stack but this should be very easily reproducible as is. Just add a table field, add some (normal) return-delimited text, run the listStyle script above, put into browse mode and click in the field... BOOM!

Please let me know if i'm doing something wrong with this - if it's likely to be a bug i'll submit a bug report...

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: Table field and listStyle

Post by dunbarx » Sat Nov 28, 2020 12:20 am

Weird.

If I run that one liner on a table field with some text in it, I get "1. xxx" etc, at the left side of line 1, "2.xxx" at line 2, etc.

Craig

stam
Posts: 3072
Joined: Sun Jun 04, 2006 9:39 pm

Re: Table field and listStyle

Post by stam » Sat Nov 28, 2020 1:12 am

dunbarx wrote:
Sat Nov 28, 2020 12:20 am
Weird.

If I run that one liner on a table field with some text in it, I get "1. xxx" etc, at the left side of line 1, "2.xxx" at line 2, etc.

Craig
Hi Craig -- yes, and that's fine, that's what i was aiming for.
But click in the field afterwards (imagine you want to edit existing text)... BOOM!

As requested, here's an example: tablefield/listStyle test

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10048
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Table field and listStyle

Post by FourthWorld » Sat Nov 28, 2020 3:30 am

Bug confirmed. It seems to come down to this function in revtablelibrary (misnamed, as it's a frontScript) not accounting for list lines:

Code: Select all

//  If the text is not seen as HTML text when it is, then the text of the
//  table field will be set to its HTMLtext (see bug 15545) 
private function isHTML pText
   put paragraphTagRegex() into tA   
   put matchText(ptext, tA) and char -4 to -1 of pText is "</p>" into tResult
   return tresult
end isHTML
I don't have time to test my hypothesis, but if someone wants to dive in an see if that fixes it then we're just one pull request away from having this done.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

stam
Posts: 3072
Joined: Sun Jun 04, 2006 9:39 pm

Re: Table field and listStyle

Post by stam » Sat Nov 28, 2020 9:52 pm

FourthWorld wrote:
Sat Nov 28, 2020 3:30 am
Bug confirmed. It seems to come down to this function in revtablelibrary (misnamed, as it's a frontScript) not accounting for list lines:

Code: Select all

//  If the text is not seen as HTML text when it is, then the text of the
//  table field will be set to its HTMLtext (see bug 15545) 
private function isHTML pText
   put paragraphTagRegex() into tA   
   put matchText(ptext, tA) and char -4 to -1 of pText is "</p>" into tResult
   return tresult
end isHTML
I don't have time to test my hypothesis, but if someone wants to dive in an see if that fixes it then we're just one pull request away from having this done.
Thanks Richard - i had a go at editing the revTableLibrary function isHTML, but couldn't resolve the issue - however i have no doubt you are correct!

I filed a bug report: https://quality.livecode.com/show_bug.cgi?id=23005
feel free to chime in there - thank you.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10048
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Table field and listStyle

Post by FourthWorld » Sun Nov 29, 2020 3:14 am

Good bug report - thanks for submitting it.

I was kinda hoping someone in our community might pick it up, since it looks like just a scripting problem and we're all scripters. Maybe someone will. It would be much faster than putting it into the company queue.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

stam
Posts: 3072
Joined: Sun Jun 04, 2006 9:39 pm

Re: Table field and listStyle

Post by stam » Sun Nov 29, 2020 5:26 am

Thanks Richard...
Hopefully this will be a simple fix and can be resolved soon. However, in the interim i did spot an "almost" workaround based on your comment.

After the text turns into html, setting the htmlText of the field to the text of the field restores the text to it's normal appearance:

Code: Select all

set the htmlText of field "table field" to the text of field "tableField"
However if you run this after the listStyle is set and before you click in the field it removes the listStyle and all line endings completely. It only works once the text has been changed into html.

I can't seem to do this automatically either - putting this code in a mouseDown or mouseUp event sets the htmlText before it turns into html and thereby ruining the appearance - both line endings and list style are removed, all the lines end up in a single line. Putting it in a textChanged handler does nothing.

Any other suggestions while we wait for a proper fix?

Post Reply