textChanged and rawKeyUp not working in table field

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
kaveh1000
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 508
Joined: Sun Dec 18, 2011 7:23 pm
Location: London
Contact:

textChanged and rawKeyUp not working in table field

Post by kaveh1000 » Sun Nov 01, 2020 12:39 am

Hi all

Please see attached minimal stack with a table field which has the following script:

Code: Select all

on rawkeyup
   answer "rawkeyup"
end rawkeyup

on textchanged
   answer "text changed"
end textchanged
Why is there no response when I edit the text?
Attachments
testing table field.zip
(1.39 KiB) Downloaded 164 times
Kaveh

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9285
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: textChanged and rawKeyUp not working in table field

Post by richmond62 » Sun Nov 01, 2020 10:40 am

I don't know what is the point of

Code: Select all

on rawkeyup
answer "rawkeyup"
end rawkeyup
because, quite frankly, "over here" it seems to block what comes next:
-
Screenshot 2020-11-01 at 11.39.54.png
-

this:

Code: Select all

on textchanged
   answer "text changed"
end textchanged
in a tableField does NOT work, but, again, in a 'normal' textField, it just blocks input after a single character has been typed:
-
Screenshot 2020-11-01 at 11.42.28.png
-
So I do wonder:

1. What are you trying to do?

2. Is this the right way to do what you want to do?

Could you, Please, try to explain the functionality you are aiming for?

kaveh1000
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 508
Joined: Sun Dec 18, 2011 7:23 pm
Location: London
Contact:

Re: textChanged and rawKeyUp not working in table field

Post by kaveh1000 » Sun Nov 01, 2020 10:50 am

Hi

There is no point as such, but just a test to see if rawKeyUp is seen by the field. When I type into the field I do not get the dialogue box that you get in your screenshot. I can just type freely.

I looked at Message Watcher and I can see that rawKeyUp is indeed sent.
Attachments
Screenshot 2020-11-01 at 09.49.19.png
Kaveh

kaveh1000
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 508
Joined: Sun Dec 18, 2011 7:23 pm
Location: London
Contact:

Re: textChanged and rawKeyUp not working in table field

Post by kaveh1000 » Sun Nov 01, 2020 12:08 pm

Apologies, Richmond. I only read the first part of your reply. :-( Thank you for your detailed reply.

I just want something to happen in the background as soon as the user has entered some text. For instance the hscroll might change in the table field. Or suppose I want LiveCode to beep as soon as the text changes. I can see that textchanged, for example, works in a normal text field. My questions is why do these handlers not work with table fields even through the message watcher shows the messages are sent?
Kaveh

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: textChanged and rawKeyUp not working in table field

Post by Klaus » Sun Nov 01, 2020 12:21 pm

Hi friends,

as far as I remember, never used a TABLE FIELD object, the TABLE FIELD script creates a NEW field on the fly,
where you enter text and then adds this to the actual text of the table field.
So your "textchanged,rawkeyup/down etc. messages do not reach this "extra" field!

To take a look at that lib, enter this in the message box -> edit script of stack "revtablelibrary"
I did and yes, LC creates a new field on the fly!


Best

Klaus

kaveh1000
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 508
Joined: Sun Dec 18, 2011 7:23 pm
Location: London
Contact:

Re: textChanged and rawKeyUp not working in table field

Post by kaveh1000 » Sun Nov 01, 2020 1:09 pm

Hi Klaus

I don't understand how LiveCode is creating a new Field on the fly. I have one field with one name in the attached stack. It just seems to be a field but with a special characteristic that it has a tabbed structure. I can't see new fields created. Any hints?
Kaveh

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: textChanged and rawKeyUp not working in table field

Post by Klaus » Sun Nov 01, 2020 1:38 pm

Hi Kaveh,

LC will delete that field immediately after hitting ENTER or RETURN to confirm the entry!
Check in the above mentioned library the handler -> revCreateCellField at line 1797.


Best

Klaus

kaveh1000
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 508
Joined: Sun Dec 18, 2011 7:23 pm
Location: London
Contact:

Re: textChanged and rawKeyUp not working in table field

Post by kaveh1000 » Sun Nov 01, 2020 1:51 pm

Amazing. Thanks for the explanation, Klaus. I understand now.
Kaveh

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9285
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: textChanged and rawKeyUp not working in table field

Post by richmond62 » Sun Nov 01, 2020 2:39 pm

LC may create a temporary field to bung text in the cell of a tableField when text is entered for the first time.

But what happens when the user attempts to append text to the first text?
Last edited by richmond62 on Sun Nov 20, 2022 2:52 am, edited 1 time in total.

Klaus
Posts: 13806
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: textChanged and rawKeyUp not working in table field

Post by Klaus » Sun Nov 01, 2020 3:09 pm

richmond62 wrote:
Sun Nov 01, 2020 2:39 pm
LC may create a temporary field to bung text in the cell of a tableField when text is entered for the first time.
Not MAY, it DOES!
richmond62 wrote:
Sun Nov 01, 2020 2:39 pm
But what happens when the user attempts tp append text to the first text?
Seriously?
They MAY copy the present text to the newly created field before showing it, not? 8)

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

Re: textChanged and rawKeyUp not working in table field

Post by dunbarx » Mon Nov 02, 2020 5:06 am

This is called a "phantom" field (my term), and is necessary to allow a table field to act like a spreadsheet. Check out this thread:
http://forums.livecode.com/viewtopic.php?f=104&t=32307

At the bottom of that thread, I said:
Hi.

Make a table field. If you simply click inside any "cell" and type, there is little to distinguish between having cell editing enabled or disabled.

Until you hit return in one of those "cells". Remember that a table field is just a field with certain properties. Having cell editing enabled allows the field to create a new "phantom" field, overlying a cell, where one can enter data. This is then loaded into the "cell" of interest. If you hit return, the cell is loaded, and the phantom field moves down one row. But if cell editing is disabled, that return is simply included "normally", and a blank row appears.

The intent of a table field really requires that editing be enabled. Did you read that thread I mentioned just a couple of posts above? It says it all.

Craig

merill001
Posts: 1
Joined: Mon Aug 01, 2022 8:56 pm

Re: textChanged and rawKeyUp not working in table field

Post by merill001 » Sat Nov 19, 2022 9:56 pm

If you use a Table Field object, your "textchanged,rawkeyup/down etc. messages do not reach this field because of the use of the temporary phantom field in "revtablelibrary."
I use "on mouseEnter" to capture the initial field text value and "on closeField" to capture the edited field text value so I can compare them to see if there was a change to the text as compared to the original value.

local tmpOrigText,tmpEditedText, grpName
on mouseEnter
put "grpBlock1" into grpName
## Capture the orignal value of the field for comparsion
put the text of fld "fldData" of grp grpName into tmpOrigText
end mouseEnter

on closeField
/*
Use closeField to capture data change
Sent to a field when the focus is being removed from that field and the field's content has changed.

use exitField if you need to confirm there were no change
Sent to the field with the selection when the
selection is being removed from the field, and its contents have not changed.
*/
put "grpBlock1" into grpName
## Capture the edited value of the field for comparsion
put the text of fld "fldData" of grp grpName into tmpEditedText
## compare orignal value to the edited value
if tmpEditedText <> tmpOrigText then
## call function to do something
get tableChanged()
end if
end closeField

Lloyd

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”