Page 2 of 2
Re: Table Field not updating correctly
Posted: Thu Aug 30, 2018 1:09 pm
by bogs
Well, using IDEs so far back in the chain as I do, I haven't had to think about it much

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

Re: Table Field not updating correctly
Posted: Thu Aug 30, 2018 1:21 pm
by bwmilby
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.
Re: Table Field not updating correctly
Posted: Thu Aug 30, 2018 2:24 pm
by dunbarx
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
Re: Table Field not updating correctly
Posted: Thu Aug 30, 2018 2:31 pm
by bogs
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

Re: Table Field not updating correctly
Posted: Thu Aug 30, 2018 2:38 pm
by bwmilby
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.
Re: Table Field not updating correctly
Posted: Thu Aug 30, 2018 3:05 pm
by bogs
Ahhhhhhh, thank you for the explanation Brian! That makes it a lot clearer (for me anyway).
Re: Table Field not updating correctly
Posted: Thu Aug 30, 2018 3:46 pm
by dunbarx
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
Re: Table Field not updating correctly
Posted: Mon Nov 05, 2018 8:38 pm
by bn
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
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
Re: Table Field not updating correctly
Posted: Mon Nov 05, 2018 8:45 pm
by ClipArtGuy
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!
Re: Table Field not updating correctly
Posted: Mon Nov 05, 2018 8:48 pm
by bn
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
Re: Table Field not updating correctly
Posted: Mon Nov 05, 2018 9:17 pm
by ClipArtGuy
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.

Re: Table Field not updating correctly
Posted: Mon Nov 05, 2018 9:26 pm
by bn
Bug reported:
https://quality.livecode.com/show_bug.cgi?id=21679
open for comments
Kind regards
Bernd
Re: Table Field not updating correctly
Posted: Tue Nov 06, 2018 5:11 pm
by bn
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
Re: Table Field not updating correctly
Posted: Thu Oct 22, 2020 2:18 pm
by dunbarx
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