Getting current line number of a table field.

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

Getting current line number of a table field.

Bob Sneidar via use-livecode
Hi,

Editing a table field (not datagrid) and need to track the number
of the line that is being edited. If I click into a new line,
"selectionchanged" will let me figure out what line I'm editing.
But if I hit return or tab to go to a new line, how can I track
what line the cursor is in? Rawkeyups and downs are being sent,
but I have been unsuccessful in trapping them in the table
field's script.

Any ideas?
Much appreciated.

Tim Selander
Tokyo, Japan

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Getting current line number of a table field.

Bob Sneidar via use-livecode
Hey-Ho . . .

I tried this script in the tableField:

on mouseDown
     put the selectedLine of me
end mouseDown

and it returned the line where I clicked.

Richmond.

On 14/2/2018 3:06 pm, Tim Selander via use-livecode wrote:

> Hi,
>
> Editing a table field (not datagrid) and need to track the number of
> the line that is being edited. If I click into a new line,
> "selectionchanged" will let me figure out what line I'm editing. But
> if I hit return or tab to go to a new line, how can I track what line
> the cursor is in? Rawkeyups and downs are being sent, but I have been
> unsuccessful in trapping them in the table field's script.
>
> Any ideas?
> Much appreciated.
>
> Tim Selander
> Tokyo, Japan
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Getting current line number of a table field.

Bob Sneidar via use-livecode
In reply to this post by Bob Sneidar via use-livecode
You know, this proved more of a problem than I thought.

Richmond, the issue is with tab and return keyPresses, not mouse clicks.
Anyway, given a table field 1 and another field 2, this works if you tab or
return in the table field:

on rawKeyUp tKey
   put the selectedLoc && the selectedChunk into fld 2
   pass rawKeyUp
end rawKeyUp

And this works fine in a button:

on mouseUp
   set the itemDel to tab
   select item 2 of line 2 of fld 1
   answer the selectedLine of fld 1
end mouseUp

But this does not in the table field:
on rawKeyDown tKey
   put "" into fld 2
   put the selectedLine into fld 2
   pass rawKeyDown
end rawKeyDown

I always get "line 1 of field 3"  (!!!!)

 Kluge city to get the line from the selectedLoc, but that would indeed
work.

Is it that in a table field, if only one "cell" is selected, the
selectedLine just does not compute?

Craig Newman






--
Sent from: http://runtime-revolution.278305.n4.nabble.com/Revolution-User-f278306.html

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Getting current line number of a table field.

Bob Sneidar via use-livecode
Try this...

on rawkeyup pkey
   send "getline" to me in 10 millisec
   pass rawkeyup
end rawkeyup

command getline
   put the short name of the focusedobject
end getline

This gives you the name of the editing field that appears for each cell in
the form of:

revCell-2,2

Parse that and voila, you have your info.

On Wed, Feb 14, 2018 at 8:35 AM, dunbarx via use-livecode <
[hidden email]> wrote:

> You know, this proved more of a problem than I thought.
>
> Richmond, the issue is with tab and return keyPresses, not mouse clicks.
> Anyway, given a table field 1 and another field 2, this works if you tab or
> return in the table field:
>
> on rawKeyUp tKey
>    put the selectedLoc && the selectedChunk into fld 2
>    pass rawKeyUp
> end rawKeyUp
>
> And this works fine in a button:
>
> on mouseUp
>    set the itemDel to tab
>    select item 2 of line 2 of fld 1
>    answer the selectedLine of fld 1
> end mouseUp
>
> But this does not in the table field:
> on rawKeyDown tKey
>    put "" into fld 2
>    put the selectedLine into fld 2
>    pass rawKeyDown
> end rawKeyDown
>
> I always get "line 1 of field 3"  (!!!!)
>
>  Kluge city to get the line from the selectedLoc, but that would indeed
> work.
>
> Is it that in a table field, if only one "cell" is selected, the
> selectedLine just does not compute?
>
> Craig Newman
>
>
>
>
>
>
> --
> Sent from: http://runtime-revolution.278305.n4.nabble.com/
> Revolution-User-f278306.html
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Getting current line number of a table field.

Bob Sneidar via use-livecode
You know, I have given advice many times to people trying to find the
selected field in a DG. The target  is always of the form, for example,
"field Col 3 0005".

But how does the focussedObject return similar data in a table field? The
fact that is does is marvelous indeed, but I never would have found that,
and if I checked the dictionary, i definitely never would have thought of
it.

A table field, after all, is but a single field, and the focusedObject ought
to return a control reference, not a non existent "cell" gizmo.

At the very least, the dictionary should include this valuable variant of
the property. And the user guide should have it in bold.

Craig



--
Sent from: http://runtime-revolution.278305.n4.nabble.com/Revolution-User-f278306.html

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Getting current line number of a table field.

Bob Sneidar via use-livecode
a table field ISN'T a single field, its a field bundled with an extra
"editing" field that pops up as an overlay.  I figured there had to be a
way to pass the cell data back to the field proper, and poked around till I
found out that the transfer mechanism is the name of the overlay field.   I
was worried that it was a property and that I'd have to dig around much
deeper to find it, but turns out it was much more straight forward than I
expected.

On Wed, Feb 14, 2018 at 9:24 AM, dunbarx via use-livecode <
[hidden email]> wrote:

> You know, I have given advice many times to people trying to find the
> selected field in a DG. The target  is always of the form, for example,
> "field Col 3 0005".
>
> But how does the focussedObject return similar data in a table field? The
> fact that is does is marvelous indeed, but I never would have found that,
> and if I checked the dictionary, i definitely never would have thought of
> it.
>
> A table field, after all, is but a single field, and the focusedObject
> ought
> to return a control reference, not a non existent "cell" gizmo.
>
> At the very least, the dictionary should include this valuable variant of
> the property. And the user guide should have it in bold.
>
> Craig
>
>
>
> --
> Sent from: http://runtime-revolution.278305.n4.nabble.com/
> Revolution-User-f278306.html
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Getting current line number of a table field.

Bob Sneidar via use-livecode
In reply to this post by Bob Sneidar via use-livecode
the mouseControl will give you the control number. If you get the long id of control (word 2 of the mouseControl) you will have the clicked object. Courtesy Trevor Devore.

Bob S

> On Feb 14, 2018, at 08:24 , dunbarx via use-livecode <[hidden email]> wrote:
>
> You know, I have given advice many times to people trying to find the
> selected field in a DG. The target  is always of the form, for example,
> "field Col 3 0005".
>
> But how does the focussedObject return similar data in a table field? The
> fact that is does is marvelous indeed, but I never would have found that,
> and if I checked the dictionary, i definitely never would have thought of
> it.
>
> A table field, after all, is but a single field, and the focusedObject ought
> to return a control reference, not a non existent "cell" gizmo.
>
> At the very least, the dictionary should include this valuable variant of
> the property. And the user guide should have it in bold.
>
> Craig
>
>
>
> --
> Sent from: http://runtime-revolution.278305.n4.nabble.com/Revolution-User-f278306.html
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Getting current line number of a table field.

Bob Sneidar via use-livecode
In reply to this post by Bob Sneidar via use-livecode
On 02/14/2018 08:04 AM, Mike Bonner via use-livecode wrote:

> Try this...
>
> on rawkeyup pkey
>     send "getline" to me in 10 millisec
>     pass rawkeyup
> end rawkeyup
>
> command getline
>     put the short name of the focusedobject
> end getline
>
> This gives you the name of the editing field that appears for each cell in
> the form of:
>
> revCell-2,2
>
> Parse that and voila, you have your info.

Brilliant. Would never have guessed that one.

--
  Mark Wieder
  [hidden email]

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Getting current line number of a table field.

Bob Sneidar via use-livecode
In reply to this post by Bob Sneidar via use-livecode
Hmm. There is a potential issue that would need to be worked around.  The
field name is the same whether one has a single table field or 12.  Perhaps
watching focus changes?  I'm back to thinking there is a property that
tracks which field to update on close of the editing overlay.  For a single
table though, the first idea works great.

Time to poke some more.

On Wed, Feb 14, 2018 at 9:28 AM, Mike Bonner <[hidden email]> wrote:

> a table field ISN'T a single field, its a field bundled with an extra
> "editing" field that pops up as an overlay.  I figured there had to be a
> way to pass the cell data back to the field proper, and poked around till I
> found out that the transfer mechanism is the name of the overlay field.   I
> was worried that it was a property and that I'd have to dig around much
> deeper to find it, but turns out it was much more straight forward than I
> expected.
>
> On Wed, Feb 14, 2018 at 9:24 AM, dunbarx via use-livecode <
> [hidden email]> wrote:
>
>> You know, I have given advice many times to people trying to find the
>> selected field in a DG. The target  is always of the form, for example,
>> "field Col 3 0005".
>>
>> But how does the focussedObject return similar data in a table field? The
>> fact that is does is marvelous indeed, but I never would have found that,
>> and if I checked the dictionary, i definitely never would have thought of
>> it.
>>
>> A table field, after all, is but a single field, and the focusedObject
>> ought
>> to return a control reference, not a non existent "cell" gizmo.
>>
>> At the very least, the dictionary should include this valuable variant of
>> the property. And the user guide should have it in bold.
>>
>> Craig
>>
>>
>>
>> --
>> Sent from: http://runtime-revolution.278305.n4.nabble.com/Revolution-
>> User-f278306.html
>>
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Getting current line number of a table field.

Bob Sneidar via use-livecode
The extra field is what I once called a "phantom" field, ephemeral and
elusive. But it does exist:

In a table field script:

on mouseEnter
   put the number of flds
end mouseEnter

If you move around the table field without a selection, you get 1, If you
click on a "cell" to "select" it, and then move around, you will get "2'.
The 2 comes because you have exited the phantom, and entered the table
field. But the phantom exists as long as the selection does.

Craig



--
Sent from: http://runtime-revolution.278305.n4.nabble.com/Revolution-User-f278306.html

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Getting current line number of a table field.

Bob Sneidar via use-livecode
For some reason I now want to name a table field "Opera."

On Wed, Feb 14, 2018 at 10:09 AM, dunbarx via use-livecode <
[hidden email]> wrote:

> The extra field is what I once called a "phantom" field, ephemeral and
> elusive. But it does exist:
>
> In a table field script:
>
> on mouseEnter
>    put the number of flds
> end mouseEnter
>
> If you move around the table field without a selection, you get 1, If you
> click on a "cell" to "select" it, and then move around, you will get "2'.
> The 2 comes because you have exited the phantom, and entered the table
> field. But the phantom exists as long as the selection does.
>
> Craig
>
>
>
> --
> Sent from: http://runtime-revolution.278305.n4.nabble.com/
> Revolution-User-f278306.html
>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Getting current line number of a table field.

Bob Sneidar via use-livecode
Found an interesting behavior.. I was trying to set up a custom control
that keeps track of the current row and column and put the script in the
group, but rawkeyup or rawkeydown messages never reach the group.  I'm
wondering if its because the message is sent to the figmentary popup field
rather than the table field, and that the popup is not part of the group.
But "the target" refers to the table field itself, so i'm not sure thats
whats happening.  Either way.. The following script works when put into a
card or stack, NOT group, and not in the table field itself.  Kinda freaky
that the message is sent, just not to where I expect, despite "the target"
still pointing back at the table field.

on mouseup
   getline
   pass mouseup
end mouseup
on rawkeyup
   getline
   pass rawkeyup
end rawkeyup

command getline
   if the short name of the focusedobject contains "revCell-" then
   put the short name of the focusedobject into tName
   replace "revCell-" with empty in tname
   set the cCol of the target to item 1 of tName
   set the cRow of the target to item 2 of tName
   end if
end getline


On Wed, Feb 14, 2018 at 10:19 AM, Mike Bonner <[hidden email]> wrote:

> For some reason I now want to name a table field "Opera."
>
> On Wed, Feb 14, 2018 at 10:09 AM, dunbarx via use-livecode <
> [hidden email]> wrote:
>
>> The extra field is what I once called a "phantom" field, ephemeral and
>> elusive. But it does exist:
>>
>> In a table field script:
>>
>> on mouseEnter
>>    put the number of flds
>> end mouseEnter
>>
>> If you move around the table field without a selection, you get 1, If you
>> click on a "cell" to "select" it, and then move around, you will get "2'.
>> The 2 comes because you have exited the phantom, and entered the table
>> field. But the phantom exists as long as the selection does.
>>
>> Craig
>>
>>
>>
>> --
>> Sent from: http://runtime-revolution.278305.n4.nabble.com/Revolution-
>> User-f278306.html
>>
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
>
>
_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: Getting current line number of a table field.

Bob Sneidar via use-livecode
In reply to this post by Bob Sneidar via use-livecode
Hi Mike,

Thanks! I put the script in the table field itself with no luck.
But when I moved it to the card script, it works! Great! I never
would have come up with that in a million years.

This list is fantastic.

Oh, and I just re-named the table field to "Opera"  ;-)

Tim Selander
Tokyo, Japan

On 2018.02.15 1:04, Mike Bonner via use-livecode wrote:

> Try this...
>
> on rawkeyup pkey
>     send "getline" to me in 10 millisec
>     pass rawkeyup
> end rawkeyup
>
> command getline
>     put the short name of the focusedobject
> end getline
>
> This gives you the name of the editing field that appears for each cell in
> the form of:
>
> revCell-2,2
>
> Parse that and voila, you have your info.
>
> On Wed, Feb 14, 2018 at 8:35 AM, dunbarx via use-livecode <
> [hidden email]> wrote:
>
>> You know, this proved more of a problem than I thought.
>>
>> Richmond, the issue is with tab and return keyPresses, not mouse clicks.
>> Anyway, given a table field 1 and another field 2, this works if you tab or
>> return in the table field:
>>
>> on rawKeyUp tKey
>>     put the selectedLoc && the selectedChunk into fld 2
>>     pass rawKeyUp
>> end rawKeyUp
>>
>> And this works fine in a button:
>>
>> on mouseUp
>>     set the itemDel to tab
>>     select item 2 of line 2 of fld 1
>>     answer the selectedLine of fld 1
>> end mouseUp
>>
>> But this does not in the table field:
>> on rawKeyDown tKey
>>     put "" into fld 2
>>     put the selectedLine into fld 2
>>     pass rawKeyDown
>> end rawKeyDown
>>
>> I always get "line 1 of field 3"  (!!!!)
>>
>>   Kluge city to get the line from the selectedLoc, but that would indeed
>> work.
>>
>> Is it that in a table field, if only one "cell" is selected, the
>> selectedLine just does not compute?
>>
>> Craig Newman
>>
>>
>>
>>
>>
>>
>> --
>> Sent from: http://runtime-revolution.278305.n4.nabble.com/
>> Revolution-User-f278306.html
>>
>> _______________________________________________
>> use-livecode mailing list
>> [hidden email]
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>
> _______________________________________________
> use-livecode mailing list
> [hidden email]
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>

_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode