DatGrid table editable field saving issue (blinking cusor)

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

Post Reply
newpie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 155
Joined: Sat Jun 29, 2013 11:24 pm

DatGrid table editable field saving issue (blinking cusor)

Post by newpie » Wed Sep 28, 2016 5:05 pm

Hello, not quite sure how to fix this issue.

Issue: When user is done editing field , but leaves cursor and hits "submit" the edited field contents does not flow into the array. (thDataA). Now if they click anywhere else (out of the edited field) then it will flow in the array with the following code:

Code: Select all

   put the dgData of group "DataGrid1" into theDataA
   put the dgIndexes of group "DataGrid1" into theIndexes
Question: Not quite sure how I can update the dgData of group when the user puts it in that state (blinking cursor). I did try to focus on another control before above code, but that did not work either.

thanks for any help
Attachments
editable Field.png
example of state of edit (blinking cursor)
editable Field.png (1.6 KiB) Viewed 4291 times

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

Re: DatGrid table editable field saving issue (blinking cuso

Post by dunbarx » Wed Sep 28, 2016 8:30 pm

Hi.

When you click on a "cell", you can get information about that cell. This is before the phantom field appears. When you enter text in an open "field" several messages are sent to the group: textChanged, the "keyDowns", the "rawKeyDowns", the "keyUps", that sort of thing.

You can work these with something like:

Code: Select all

on rawkeyUp tKey
   put tKey && the target --phantom field
end rawkeyUp

on mouseDown
   put the name of the target --row and column designator
end mouseDown
This will give you the actual "cell" you clicked on, and then the value of the keyPress.

So is this of any help? I guess you have an external "submit" button somewhere, and that might either help or hinder your thinking. But you can always store the current value of the open "cell" and refresh the group.

Craig Newman

newpie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 155
Joined: Sat Jun 29, 2013 11:24 pm

Re: DatGrid table editable field saving issue (blinking cuso

Post by newpie » Thu Sep 29, 2016 2:10 am

Hello, Craig thank you for your reply.

Would updating a custom property called "cellEdit" with true and then when they leave change to false. Then check the value when submit button is hit, if true it would warn them to click out of Editing Cell before continuing. Is this possible?

Thanks

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

Re: DatGrid table editable field saving issue (blinking cuso

Post by dunbarx » Thu Sep 29, 2016 3:54 am

Certainly.

You can set (and read) a custom property in any handler, initiated by any message. Your choice. Open the message watcher, suppress IDE messages so you can make sense of the many that will pop up every time you take a breath, and play with the procedures you want to work with. Find a message you like and trap it in the group script.

As for getting out of (defocusing) edit mode in the DG, here is an old trick, likely now supplanted by more modern and pertinent methods:

Code: Select all

on mouseUp
click at "-1,-1"
end mouseUp
Craig

newpie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 155
Joined: Sat Jun 29, 2013 11:24 pm

Re: DatGrid table editable field saving issue (blinking cuso

Post by newpie » Fri Sep 30, 2016 1:59 pm

Thank you for the tips Craig I will try them out.

MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Re: DatGrid table editable field saving issue (blinking cuso

Post by MaxV » Tue Oct 04, 2016 3:21 pm

newpie wrote:Hello, not quite sure how to fix this issue.

Issue: When user is done editing field , but leaves cursor and hits "submit" the edited field contents does not flow into the array. (thDataA). Now if they click anywhere else (out of the edited field) then it will flow in the array with the following code:

Code: Select all

   put the dgData of group "DataGrid1" into theDataA
   put the dgIndexes of group "DataGrid1" into theIndexes
Question: Not quite sure how I can update the dgData of group when the user puts it in that state (blinking cursor). I did try to focus on another control before above code, but that did not work either.

thanks for any help
Why did you use that code? If datagrid has

Code: Select all

set the dgProp["allow editing"] of group "Data Grid" to true
you don't need any code.
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

Post Reply