Page 1 of 1
Intercepting messages in a editable table field
Posted: Tue Aug 27, 2013 2:01 pm
by MaxV
Hi,
I have a simple task, using an editable table field: when user add data, something happen.
The problem seem that an editable table field doesn't pass enterInField, returnInField, TabKey messages! They are used internally and passed no more!
How can I intercept those message in an editable table field?
Re: Intercepting messages in a editable table field
Posted: Tue Aug 27, 2013 2:34 pm
by Martin Koob
Hi
If you handle enterInField in the field script then the enterInField message won't pass further along the message path unless you tell it to do so with a pass statement
ie
on enterInField
answer "field"
pass enterInField
end enterInField
This will pass the message to the next object in the path be it a group or the card where it can be handled again.
If you don't handle enterInField in the field script it will pass along the message path until it is handled by a group, the card, the stack etc.
Martin
Re: Intercepting messages in a editable table field
Posted: Tue Aug 27, 2013 3:14 pm
by MaxV
It's not so easy. In a simple field
on enterInField scripts works, but if you transform the field in a basic table (property->Table->Basic table object ON and Cell editing ON) you can't intercept keys as usual, for example this don't work:
Code: Select all
on returninfield
Answer "hello"
pass returninfield
end returninfield
on enterinfield
Answer "hello"
pass enterinfield
end enterinfield
on tabKey
Answer "hello"
pass tabKey
end tabKey
Re: Intercepting messages in a editable table field
Posted: Tue Aug 27, 2013 3:58 pm
by dunbarx
In a table field, the engine creates a "phantom" field that overlies the cell of interest. It is this phantom field that does all the work.
Make a table field on a blank card. Put this into the card script:
Code: Select all
on enterinfield
put the value of target & return & the name of the target
end enterinfield
Type into a cell, and hit "enter".
You have to use this field when trying to manipulate the table field functionality.
Craig Newman
Re: Intercepting messages in a editable table field
Posted: Tue Aug 27, 2013 9:54 pm
by Martin Koob
Sorry MaxV.
I missed the fact you were talking about a table field.
Martin
Re: Intercepting messages in a editable table field
Posted: Wed Aug 28, 2013 11:41 am
by MaxV
WOW it isn't just a single field, but every cell has a its phantom field like
field "revCell-2,1".
At the moment I bypassed the problem with an external button ("FINISHED TO USE TABLE"

) .
However what is the best object to use for an editable table? For example: I wish to save all table data every time a cell is edited.
Datagrid is not editable like table field, user can't add data, so any suggestion?
Re: Intercepting messages in a editable table field
Posted: Wed Aug 28, 2013 3:50 pm
by Martin Koob
Hi I have to admit that I don't really know how table fields work. Out of curiosity I thought I would look at the message watcher to see what happens when you edit a table field. There are a lot of messages cREVtable flying around. Some with the data that is entered as parameters, many with no parameters. If a phantom field is closed you can catch when that happens with getProp cREVtable and look at the target. The target name contains the cell that was closed but doesn't tell you if it was edited or not but tells you the user left the field so there is a chance they did something while it was open. If you press return in the field you can also catch the returnInField the same way but a cREVtable will also be sent from the phantom field.
Here are some test handlers to put in the stack script to catch those events.
Code: Select all
getprop cREVtable
if the short name of the target contains "REVcell" then
answer "Close" && char 9 to - 1 of the short name of the target
end if
pass cREVtable
end cREVtable
on returninfield
if the short name of the target contains "REVcell" then
answer "return" && char 9 to - 1 of the short name of the target
end if
pass returninfield
end returninfield
Another interesting thing is that if you put those two handlers in the card script the cREVtable message is handled by the card but the returnInField message is not.
Further more if you put those two handlers in a group script that contains the table field the neither the cREVtable message nor returnInField message is handled by the group.
Again I don't know know enough about this to know if this would work for your purposes but I thought it was interesting so I thought I would pass this along.
Re: Intercepting messages in a editable table field
Posted: Wed Aug 28, 2013 4:06 pm
by dunbarx
Martin.
Pretty sure that there is only one phantom field, the engine creating, sizing and naming it according to the loc of the mouseclick. LC knows, after all,where its tabs and lines are, and you or I for that matter, could do the same. The field is ephemeral, created and destroyed as needed.
It allows there to be only a single table field, formatted as we see, and a single "working" field, like a virtual particle in empty space, to manage the very convenient functionality of that field type.
Craig