Charles Poole wrote: > Is there a way to link the arrow keys to a scroll bar that is linked > to an edit field? Charles, While this could be done in FB's event handler, it might be easier to intercept the arrow keys in the dialog handler. Take a look at this example I threw together for you. Notice that the scroll bar position is directly related to the caret location in the text. This is how it should be handled. If you are unaware of the caret position, you may think there is a lag in scroll bar movement with the arrow keys, but the keys are actually controlling the caret which, in turn, activates the edit field when it reaches the top or bottom of the field's rect. The dialog handler continuously adjusts the scroll button's thumb to correspond with caret movement. In the case of multiple edit fields, the routine could be wrapped into a function for control of the currently active edit field and its linked scroll bar, to be called when the up and down arrow keys are pressed. Ken /* Scrolling Edit Field with arrow keys Ken Shmidheiser August 17, 2007 */ begin globals dim as container gC end globals gC = "'Twas brillig, and the slithy toves" + chr$(13) gC += "Did gyre and gimble in the wabe;" + chr$(13) gC += "All mimsy were the borogoves," + chr$(13) gC += "And the mome raths outgrabe." + chr$(13) gC += chr$(13) gC += "'Beware the Jabberwock, my son!" + chr$(13) gC += "The jaws that bite, the claws that catch!" + chr$(13) gC += "Beware the Jubjub bird, and shun" + chr$(13) gC += "The frumious Bandersnatch!'" + chr$(13) gC += chr$(13) gC += "He took his vorpal sword in hand:" + chr$(13) gC += "Long time the manxome foe he sought--" + chr$(13) gC += "So rested he by the Tumtum tree," + chr$(13) gC += "And stood awhile in thought." + chr$(13) gC += chr$(13) gC += "And as in uffish thought he stood," + chr$(13) gC += "The Jabberwock, with eyes of flame," + chr$(13) gC += "Came whiffling through the tulgey wood," + chr$(13) gC += "And burbled as it came!" + chr$(13) gC += chr$(13) gC += "One, two! One, two! And through and through" + chr$(13) gC += "The vorpal blade went snicker-snack!" + chr$(13) gC += "He left it dead, and with its head" + chr$(13) gC += "He went galumphing back." + chr$(13) gC += chr$(13) gC += "'And has thou slain the Jabberwock?" + chr$(13) gC += "Come to my arms, my beamish boy!" + chr$(13) gC += "O frabjous day! Callooh! Callay!'" + chr$(13) gC += "He chortled in his joy." + chr$(13) gC += chr$(13) gC += "'Twas brillig, and the slithy toves" + chr$(13) gC += "Did gyre and gimble in the wabe;" + chr$(13) gC += "All mimsy were the borogoves," + chr$(13) gC += "And the mome raths outgrabe. _EFandScrollBtn = 10 _margin = 4 local fn BuildWindow dim as rect r setrect( r, 0, 0, 350, 250 ) appearance window -1, "", @r,¬ _kDocumentWindowClass,¬ _kWindowCloseBoxAttribute def SetWindowBackground(_kThemeActiveDialogBackgroundBrush, _zTrue ) edit = _margin text _courier, 12 setrect( r, 20, 20, 314, 190 ) edit field -_EFandScrollBtn, "", @r, _framed _noDrawFocus, _leftJust setrect( r, 314, 20 - _margin, 330, 190 + _margin ) scroll button -_EFandScrollBtn, 0, 0, 0, 0, @r, _scrollOther edit$( _EFandScrollBtn ) = #gC /* Activate the edit field and set caret at start */ edit field _EFandScrollBtn setselect 0, 0 setrect( r, 265, 210, 330, 230 ) button 1, _activeBtn, "Quit", @r, _push window 1 end fn local fn DoDialog dim as long evnt, id dim as long thumb, current dim as long min, max evnt = dialog( 0 ) id = dialog( evnt ) /* Assign constants to arrow keys */ _upArrow = 30 _downArrow = 31 select case ( evnt ) case _btnclick select (id ) case 1 : end end select /* Look at key presses... */ case _evkey /* ... checking for up and down arrow key presses */ long if ( id = _upArrow or id = _downArrow ) /* Activate the target edit field */ edit field _EFandScrollBtn /* Get caret's last position and set it there */ setselect window( _selStart ), window( _selEnd ) /* Get current position of EF's scroll button thumb */ thumb = button( _EFandScrollBtn ) select case ( id ) /* Assign up arrow key press */ case _upArrow if thumb > button( _EFandScrollBtn,¬ _FBGetCtlMinimum ) then thumb-- /* Assign down arrow key press */ case _downArrow if thumb < button( _EFandScrollBtn,¬ _FBGetCtlMaximum ) then thumb++ end select /* Set scroll button thumb to new value */ scroll button _EFandScrollBtn, thumb end if case _wndclose : end end select end fn on dialog fn DoDialog fn BuildWindow do handleevents until gFBQuit end