Page 1 of 1

Keyboard scroll ??

Posted: Tue Jul 04, 2006 2:27 am
by Timothy
Sorry, I don't know what to call this subject line.

I frequently deal with loonngg vertically scrolling fields. They are clickable index fields, which navigate to cards in a stack with more than 1000 cards. The fields are alphabetized.

So, I'm often scrolling through these fields, looking for a last name, then a first name, typically. When I do it, I think wistfully of Apple dialog boxes with scrolling fields. Like Open and Save as... dialog boxes. If I type the first letter or two of what I'm looking for, the field scrolls down to the first line that matches the letters I've typed.

I hope I made that clear. If I did...

Is there a reasonable easy way to make RR work this way, on designated cards with long scrolling fields?

Thanks,


Tim

Posted: Tue Jul 04, 2006 4:09 am
by Benedikt.Seidl
set the code of fld to this script:

Code: Select all

on keydown thekey
  lock screen
  put 0 into i
  repeat for each line tline in the text of me
    add 1 to i
    if char 1 of tline is thekey then
      exit repeat
    end if
  end repeat
  put i * the textheight of fld 1
  if the textheight of me is empty then set the textheight of me to 14
  set the scroll of me to ( i * the textheight of me )
  select line i of me
  unlock screen
end keydown
i tested it with exact 1000 lines and it worked very fast.

i hope it is usefull for you

SEIDL.

Posted: Tue Jul 04, 2006 4:26 am
by Janschenkel
Hi Tim,

You can write a keyUp handler in your card script, and react to what the user types. Here's something to get you started:

Code: Select all

--- script local variable declarations
local sFindString
local sResetMsgID

-- engine message handlers
on keyUp pKey
  put pKey after sFindString
  -- use 'send in time' costruct to improve performance
  if "ScrollToFindString" is not in the pendingMessages
  then send "ScrollToFindString" to me in 25 milliseconds
end keyUp

on backspaceKey
  delete char -1 of sFindString
  -- use 'send in time' costruct to improve performance
  if "ScrollToFindString" is not in the pendingMessages
  then send "ScrollToFindString" to me in 25 milliseconds
end backspaceKey

-- custom handlers
on ScrollToFindString
  put return & sFindString into tFindString
  put return & field "Scrolling List Field" into tFieldString
  put lineOffset(tFindString, tFieldString) into tLineOffset
  set the hilitedLine of field "Scrolling List Field" to tLineOffset
  -- give the user some time before resetting the find string
  if sResetMsgID is not empty then
    cancel sResetMsgID
  end if
  -- use 'send in time' construct and save the message ID to cancel
  send "ResetFindString" to me in 4 seconds
  put the result into sResetMsgID
end ScrollToFindString

on ResetFindString
  -- clean up local variables
  put empty into sFindString
  put empty into sResetMsgID
end ResetFindString
The above script worked for me in Rev 2.7.2, but I had to leave some time between the different letters.

Hope thgis helped,

Jan Schenkel.

Posted: Tue Jul 04, 2006 9:34 am
by Mark
Hi Tim,

Why don't you create a field that, on rawKeyUp, filters a list and puts the result into your list field? That is probably easier than scrolling very long list fields.

-- assume cList is a custom prop
-- containing all data
on rawKeyUp
put the cList of this stack into myList
filter myList with (me & "*")
put myList into fld "Your list field"
end rawKeyUp

Best,

Mark

Posted: Wed Jul 05, 2006 4:45 am
by Timothy
Thanks everybody.

Wow! I didn't know about the "Filter" command.

Who knows how many other great features await my discovery.

In any case, this seems very do-able now. Thanks again. :D

Tim

Posted: Wed Jul 19, 2006 6:55 pm
by Timothy
Suggestions were excellent. I ended up using Jan's script. It worked perfectly right out of the box. All I had to do was type in the field name.

Tim