Page 1 of 1
tab into table and use up/down arrow keys to navigate
Posted: Fri Nov 07, 2008 1:12 pm
by billworld
I'm not figuring out how to tab into a field and allow one to immediately use the up/down arrows to navigate, preferably starting from the location of the last hilited line.
I've been searching and experimenting with various options. For example, the following doesn't work.
Code: Select all
on focusin
click at the hilitedLine
end focusin
We know what the hilitedLine is. How do we recognize that location as the starting point for keyboard navigation once entering the field?
I'm sure this is brain-dead easy.
Posted: Fri Nov 07, 2008 1:25 pm
by Mark
Hi Bill,
It seems that you have to click in the field to make the arrowKeys work, which is a silly situation of course.
Try this in your list field:
Code: Select all
on arrowKey theKey
put the hilitedLine of me into myLine
if theKey is up then
put max(1,myLine-1) into myLine
else if theKey is down then
put min(number of lines of me,myLine+1) into myLine
else
pass arrowKey
end if
set the hilitedLine of me to myLine
end arrowKey
Best,
Mark
Posted: Fri Nov 07, 2008 1:30 pm
by billworld
That works. Thanks!
Mark wrote:Hi Bill,
It seems that you have to click in the field to make the arrowKeys work, which is a silly situation of course.
Try this in your list field:
Code: Select all
on arrowKey theKey
put the hilitedLine of me into myLine
if theKey is up then
put max(1,myLine-1) into myLine
else if theKey is down then
put min(number of lines of me,myLine+1) into myLine
else
pass arrowKey
end if
set the hilitedLine of me to myLine
end arrowKey
Best,
Mark
Posted: Fri Nov 07, 2008 2:08 pm
by billworld
Now I'm stuck on the issue of being able to press the return key (after using the keyboard to navigate into the table) to grab data from the current line. I've set a local var on myLine to pick up the up/down key line setting, and I'm getting that data into the returnInField handler. However, I'm not seeing how to get values out of that line. The "set the selectedLine to myLine" code is incorrect, but, conceptually that's what needs to occur. How do I transfer the concept of what's set in myLine to becoming the current selectedLine from which I can then grab values?
Code: Select all
on returnInField
set the itemDelimiter to tab
set the selectedLine to myLine
answer item 1 of the value of selectedLine
end returnInField
Thanks
Bill
billworld wrote:That works. Thanks!
Mark wrote:Hi Bill,
It seems that you have to click in the field to make the arrowKeys work, which is a silly situation of course.
Try this in your list field:
Code: Select all
on arrowKey theKey
put the hilitedLine of me into myLine
if theKey is up then
put max(1,myLine-1) into myLine
else if theKey is down then
put min(number of lines of me,myLine+1) into myLine
else
pass arrowKey
end if
set the hilitedLine of me to myLine
end arrowKey
Best,
Mark
Posted: Fri Nov 07, 2008 2:14 pm
by billworld
Actually, to further clarify, there needs to be a way for myLine to be recognized as the currently selectedLine. For example, I could click on a line and then hit the return key or navig. up/down with arrow keys and then hit the return key and what gets returned would be the same. This is where I'm stumbling, transferring the concept of what is visually selected via either the mouse or keyboard to the concept of what is actually known to be selected. Hopefully that's clear.
billworld wrote:Now I'm stuck on the issue of being able to press the return key (after using the keyboard to navigate into the table) to grab data from the current line. I've set a local var on myLine to pick up the up/down key line setting, and I'm getting that data into the returnInField handler. However, I'm not seeing how to get values out of that line. The "set the selectedLine to myLine" code is incorrect, but, conceptually that's what needs to occur. How do I transfer the concept of what's set in myLine to becoming the current selectedLine from which I can then grab values?
Code: Select all
on returnInField
set the itemDelimiter to tab
set the selectedLine to myLine
answer item 1 of the value of selectedLine
end returnInField
Thanks
Bill
billworld wrote:That works. Thanks!
Mark wrote:Hi Bill,
It seems that you have to click in the field to make the arrowKeys work, which is a silly situation of course.
Try this in your list field:
Code: Select all
on arrowKey theKey
put the hilitedLine of me into myLine
if theKey is up then
put max(1,myLine-1) into myLine
else if theKey is down then
put min(number of lines of me,myLine+1) into myLine
else
pass arrowKey
end if
set the hilitedLine of me to myLine
end arrowKey
Best,
Mark
Posted: Fri Nov 07, 2008 3:25 pm
by SparkOut
Hi Bill,
You need to have a look in the documentation to see the distinction between the "selectedLine" and the "hilitedLine"
selectedLine is a function and returns a chunk expression containing information about the currently selected line(s)
Rev dictionary wrote:The selectedLine function returns a chunk expression of the form
line lineNumber of field fieldNumber
if the text selection is on one line, or
line startLine to endLine of field fieldNumber
if the text selection crosses multiple lines.
hilitedLine is a property that can be interrogated, or set
Rev dictionary wrote:The hilitedLine of a field is a list of one or more integers, separated by commas.
So your code
Code: Select all
on returnInField
set the itemDelimiter to tab
set the selectedLine to myLine
answer item 1 of the value of selectedLine
end returnInField
should probably be along the lines of
Code: Select all
on returnInField
set the itemDelimiter to tab
set the hilitedLine of me to myLine
answer item 1 of line the hilitedLine of me
-- or answer item 1 of (the selectedLine)
-- or answer item 1 of line myLine of field "targetField"
-- etc
end returnInField
Posted: Fri Nov 07, 2008 3:42 pm
by billworld
Yeah, I was going down the wrong path. As I had the right row with hilitedLine, all I then needed to do is:
Code: Select all
answer item 1 of line myLine of me
rather than trying to figure out what the selectedLine was/is and try to pull a value out of that.
Anyway, got it.
Thanks, and sorry for the trouble!
SparkOut wrote:Hi Bill,
You need to have a look in the documentation to see the distinction between the "selectedLine" and the "hilitedLine"
Rev dictionary wrote:The selectedLine function returns a chunk expression of the form
line lineNumber of field fieldNumber
if the text selection is on one line, or
line startLine to endLine of field fieldNumber
if the text selection crosses multiple lines.
Rev dictionary wrote:The hilitedLine of a field is a list of one or more integers, separated by commas.
Posted: Fri Nov 07, 2008 3:44 pm
by SparkOut
OK!
Posted: Fri Nov 07, 2008 7:23 pm
by bn
Bill,
to activate the arrowkeys you can put
Code: Select all
-- activates the arrowkeys
if (the hilitedline of me) <> "" then -- in case there is no selection
select line (item 1 of the hilitedline of me) of me -- in case there is multiple selections
else select line 1 of me
into the focusIn handler and you dont have to trap for the arrowkeys.
regards
bernd
Posted: Fri Nov 07, 2008 7:55 pm
by billworld
That approach is closer to the direction I was initially thinking and it does work at first, HOWEVER, it doesn't handle situations where you open a dialog based on the current row and then after returning to the row you need to arrow up/down with the keyboard. That doesn't work. So, unless there's a way to account for that scenario with this more streamlined approach, I'm going with trapping for the arrowkeys.
bn wrote:Bill,
to activate the arrowkeys you can put
Code: Select all
-- activates the arrowkeys
if (the hilitedline of me) <> "" then -- in case there is no selection
select line (item 1 of the hilitedline of me) of me -- in case there is multiple selections
else select line 1 of me
into the focusIn handler and you dont have to trap for the arrowkeys.
regards
bernd
Posted: Fri Nov 07, 2008 9:00 pm
by billworld
Actually, for this portion of the code (for those who might be interested) I'm finding I need to account in this handler for situations where multiple lines are selected. (A different handler requires the ability to handle multiple lines, so, I need to trap for both scenarios.)
So, I need to do the following for the handler which fails if more than a single row is selected:
Code: Select all
on returnInField
set the itemDelimiter to tab
put the hilitedLine of me into myLine
if myLine contains comma
then answer "Please select just one record."
else answer item 1 of line myLine of me
end returnInField
billworld wrote:Yeah, I was going down the wrong path. As I had the right row with hilitedLine, all I then needed to do is:
Code: Select all
answer item 1 of line myLine of me
rather than trying to figure out what the selectedLine was/is and try to pull a value out of that.
Anyway, got it.
Thanks, and sorry for the trouble!
SparkOut wrote:Hi Bill,
You need to have a look in the documentation to see the distinction between the "selectedLine" and the "hilitedLine"
Rev dictionary wrote:The selectedLine function returns a chunk expression of the form
line lineNumber of field fieldNumber
if the text selection is on one line, or
line startLine to endLine of field fieldNumber
if the text selection crosses multiple lines.
Rev dictionary wrote:The hilitedLine of a field is a list of one or more integers, separated by commas.
Posted: Fri Nov 07, 2008 10:07 pm
by bn
Bill,
I don't quite get what you want.
This code passes the selected line/lines to the answer dialog. It is this you're looking for?
Code: Select all
on returnInField
put the hilitedline of me into tHilited
put the number of items of tHilited into tCountLines
if tCountLines < 2 and tCountLines >0 then -- -> 1 line selected
put line (item 1 of the hilitedline of me) of me into tAnswer
else -- -> more than 1 line selected
repeat for each item aSelectedLineNumber in tHilited
put line aSelectedLineNumber of me & return after tAnswer
end repeat
delete char -1 of tAnswer -- return
end if
answer tAnswer
end returnInField
this doesnt take care of case no line selected
regards
bernd
Posted: Fri Nov 07, 2008 11:29 pm
by billworld
Thanks, but, I got that part of the code working fine now (as I posted above). The desired effect was NOT to pass all selected lines to an answer handler, but, to require the user to select a single line for that particular handler (e.g. to navigate to a detailed record which for now is just going to a dialog). That was auxiliary functionality to the initial post for this thread.
There are other sections of the code I'm still working on (not this section). Namely, I'm trying to merge the two arrowkey approaches Mark recently posted (one in this thread and the other in a different thread). In short, those are:
1. get in the field and immediately navigate using the keyboard arrows (but still need to account for continuous keyboard navigation even after a dialog is called up) <--- This solved the initial question posed in this thread
2. shift-select multiple lines using just the keyboard). <--- Mark provided a routine for this in a diff. thread
I don't have it worked out yet. The two arrowkey approaches are not living harmoniously with one another. Will probably have to take a break from it as I'm head-banging right now.
bn wrote:Bill,
I don't quite get what you want.
This code passes the selected line/lines to the answer dialog. It is this you're looking for?
Code: Select all
on returnInField
put the hilitedline of me into tHilited
put the number of items of tHilited into tCountLines
if tCountLines < 2 and tCountLines >0 then -- -> 1 line selected
put line (item 1 of the hilitedline of me) of me into tAnswer
else -- -> more than 1 line selected
repeat for each item aSelectedLineNumber in tHilited
put line aSelectedLineNumber of me & return after tAnswer
end repeat
delete char -1 of tAnswer -- return
end if
answer tAnswer
end returnInField
this doesnt take care of case no line selected
regards
bernd