Page 1 of 1

textChanged and rawKeyUp not working in table field

Posted: Sun Nov 01, 2020 12:39 am
by kaveh1000
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?

Re: textChanged and rawKeyUp not working in table field

Posted: Sun Nov 01, 2020 10:40 am
by richmond62
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?

Re: textChanged and rawKeyUp not working in table field

Posted: Sun Nov 01, 2020 10:50 am
by kaveh1000
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.

Re: textChanged and rawKeyUp not working in table field

Posted: Sun Nov 01, 2020 12:08 pm
by kaveh1000
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?

Re: textChanged and rawKeyUp not working in table field

Posted: Sun Nov 01, 2020 12:21 pm
by Klaus
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

Re: textChanged and rawKeyUp not working in table field

Posted: Sun Nov 01, 2020 1:09 pm
by kaveh1000
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?

Re: textChanged and rawKeyUp not working in table field

Posted: Sun Nov 01, 2020 1:38 pm
by Klaus
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

Re: textChanged and rawKeyUp not working in table field

Posted: Sun Nov 01, 2020 1:51 pm
by kaveh1000
Amazing. Thanks for the explanation, Klaus. I understand now.

Re: textChanged and rawKeyUp not working in table field

Posted: Sun Nov 01, 2020 2:39 pm
by richmond62
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 tp append text to the first text?

Re: textChanged and rawKeyUp not working in table field

Posted: Sun Nov 01, 2020 3:09 pm
by Klaus
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)

Re: textChanged and rawKeyUp not working in table field

Posted: Mon Nov 02, 2020 5:06 am
by dunbarx
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