Table Field not updating correctly

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

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Table Field not updating correctly

Post by bogs » Thu Aug 30, 2018 1:09 pm

Well, using IDEs so far back in the chain as I do, I haven't had to think about it much :oops: but I think -
  • Your solution is clever , and
  • it appears to supply a work around to the issue, and
  • your thinking is valid (it is weird to me also, but I lack enough knowledge to know exactly why, so weird more in a "curiosity" way).
In a side note, just changing the cell editing technique from clicking with a mouse to using the arrow keys to navigate instead seems to not produce the issue (i.e. it works as I'd expect it to). Also weird :wink:
Image

bwmilby
Posts: 439
Joined: Wed Jun 07, 2017 5:37 am
Location: Henrico, VA
Contact:

Re: Table Field not updating correctly

Post by bwmilby » Thu Aug 30, 2018 1:21 pm

Looking at the code, I can see why arrow keys work. Knowing that should make finding a solution easier. I kind of doubt that it is random, I’m guessing there will be a pattern too.
Brian Milby

Script Tracker https://github.com/bwmilby/scriptTracker

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9663
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Table Field not updating correctly

Post by dunbarx » Thu Aug 30, 2018 2:24 pm

I kind of doubt that it is random, I’m guessing there will be a pattern too.
I think so too. Something "sticks" in the innards of a table field when a "cell" has had something put into it. The craziness occurs upon exiting the "phantom" field LC creates to simulate text entry in a "cell". The team should be able to isolate the problem readily.

So many parenthetical words in this discussion.

Craig

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Table Field not updating correctly

Post by bogs » Thu Aug 30, 2018 2:31 pm

bwmilby wrote:
Thu Aug 30, 2018 1:21 pm
Looking at the code, I can see why arrow keys work.
Please, for those of us in the slower camp, feel free to elaborate :D
Image

bwmilby
Posts: 439
Joined: Wed Jun 07, 2017 5:37 am
Location: Henrico, VA
Contact:

Re: Table Field not updating correctly

Post by bwmilby » Thu Aug 30, 2018 2:38 pm

There is code (handlers) to go to the next/previous row/cell (one for each direction). When navigating that way, tabs are automatically inserted. My guess is that something is amiss with the calculation of tabs that need to get inserted when clicking on an arbitrary cell. The location is good in one sense because it puts the virtual cell (field) where it needs to go, but then the data does not end up in the correct spot.
Brian Milby

Script Tracker https://github.com/bwmilby/scriptTracker

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: Table Field not updating correctly

Post by bogs » Thu Aug 30, 2018 3:05 pm

Ahhhhhhh, thank you for the explanation Brian! That makes it a lot clearer (for me anyway).
Image

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9663
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Table Field not updating correctly

Post by dunbarx » Thu Aug 30, 2018 3:46 pm

Brian is likely on to something.

And maybe that is why it matters if a "cell" has (or has not) been pre-loaded under script control. There are no phantom fields and none of the concomitant messages generated by user action. The tabs are "loaded" via a different methodology (a handler), and somehow those tabs stick, "stabilizing" the table field.

Craig

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

Re: Table Field not updating correctly

Post by bn » Mon Nov 05, 2018 8:38 pm

After I saw a reference to this thread I had a look at the problems of manually inserting data into a table field via "cell edit"

bogs wrote
I did find this bug report https://quality.livecode.com/show_bug.cgi?id=18983, but aint sure if it is the same thing or not.
reported dec 2016.
Indeed that is the root of the problem of manually entering data via "input field"
automatically creating items when setting the htmlText of a non-existent item fails starting version 7 of LC.

I did a patch for stack "revTableLibrary" that fixes the problem for the table field.

Those who feel adventurous can fix it temporarily by replacing the handler "revWriteCellField" in stack "revTableLibrary" with below code. The patch is marked.
You can open the stack "revTableLibrary" by using the Project Browser and start replacing handler "revWriteCellField"
Stack "revTableLibrary" is also listed in the front scripts -> Project Browser.

If you quit LC the changes will be gone and you would have to apply the patch again next time you open LC.

In my testing it works. More people testing this would be welcome.

I will do a separate bug report for this and propose the fix, if accepted I will do a pull-request.

Kind regards
Bernd

Code: Select all

on revWriteCellField pObject
   --revSetScrollInfo pObject
   put the cREVTable["currentxcell"] of pObject into txcell
   put the cREVTable["currentycell"] of pObject into tycell 
   put the cREVTable["currentview"] of pObject into tCurrentView
   put revGetCellName(pObject) into tFieldName 
   
   if there is not a field tFieldName then exit revWriteCellField
   put the long ID of field tFieldName into tFieldRef
   put the text of field tFieldName into tNewText
   put the htmltext of field tFieldName into tNewHtmlText
   -- now that we have what we need, abuse the temp field a bit *chuckle*
   lock screen
   lock messages
   -- if the currentview is not yet in htmlText, make sure to convert it
   if isHTML(tCurrentView)
   then set the htmltext of field tFieldName to tCurrentView
   else set the text of field tFieldName to tCurrentView
   set the itemDelimiter to tab
   
   # Patch for bug 18983
   if the number of items of line tycell of field tFieldName < txcell then
      put empty into item txcell of line tycell of field tFieldName
   end if
   # end patch
   
   put the htmltext of item txcell of line tycell of field tFieldName into tCurrentHtmlText
   if tCurrentHtmltext contains "#9;" then
      put "<p></p>" into tCurrentHtmlText
   end if
   ## NOTE :: DO NOT REMOVE THE LOCK MESSAGES OR YOU'LL GET AN ERROR AFTER SETTING THE HTMLTEXT !!!
   if not (tNewHtmlText = tCurrentHtmlText) then
      set the htmltext of item txcell of line tycell of tFieldRef to tNewHtmlText
      set the cREVTable["currentview"] of pObject to the htmlText of tFieldRef
      try -- this has to be try because there may not be a database library in a standalone
         send "revUpdateDatabase pObject,txcell,tycell,tNewText" to pObject
      catch tError
      end try
   end if
   -- and unlock things again
   unlock messages
   unlock screen
   -- move on with the other updates
   revUpdateScrollInfo pObject
   revDisplayFormattedData pObject
   if exists(pObject) then
      send "revUpdateCellValue pObject,txcell,tycell,tcurrentcell,tNewText" to pObject
   end if
end revWriteCellField
Last edited by bn on Mon Nov 05, 2018 8:50 pm, edited 1 time in total.

ClipArtGuy
Posts: 253
Joined: Wed Aug 19, 2015 4:29 pm

Re: Table Field not updating correctly

Post by ClipArtGuy » Mon Nov 05, 2018 8:45 pm

This fix is working here in LC 9.01 on Ubuntu 18.04. The only difference, is the stack with the "revWriteCellField" handler is actually named "revTableLibrary"

Thanks!

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

Re: Table Field not updating correctly

Post by bn » Mon Nov 05, 2018 8:48 pm

Thanks for testing.
The only difference, is the stack with the "revWriteCellField" is actually named "revTableLibrary"
Some day I will do a post without goofing it up, promised.... :)

Will correct it in the post.

KInd regards
Bernd

ClipArtGuy
Posts: 253
Joined: Wed Aug 19, 2015 4:29 pm

Re: Table Field not updating correctly

Post by ClipArtGuy » Mon Nov 05, 2018 9:17 pm

I wasn't 100% sure whether or not the stack had a different name based on platform. Either way, thank you for the fix, it's much appreciated. :D

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

Re: Table Field not updating correctly

Post by bn » Mon Nov 05, 2018 9:26 pm

Bug reported:

https://quality.livecode.com/show_bug.cgi?id=21679

open for comments

Kind regards
Bernd

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

Re: Table Field not updating correctly

Post by bn » Tue Nov 06, 2018 5:11 pm

Pull-request

https://github.com/livecode/livecode-ide/pull/2010

the pull-request is against develop 9.0 which means that it should/could be included in 9.0.2 rc1 if the pull-request is accepted in its current form.

Kind regards
Bernd

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9663
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: Table Field not updating correctly

Post by dunbarx » Thu Oct 22, 2020 2:18 pm

I just checked a new table field. The issue remains. I have not tested Bernd's offering, But this, applied to a new table field immediately after creation, still works:

Code: Select all

on mouseUp
   set the itemDel to tab
     repeat with x = 1 to 200
      repeat with u = 1 to 200
         put "" into item u of line x of temp
      end repeat
   end repeat
   put temp into fld "yourTableField"
end mouseUp
This assumes that 200 is adequate for the use case.

Craig

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”