************************************************** *-- Class: cbogrddropdown *-- ParentClass: combobox *-- BaseClass: combobox *-- Drop Down List for use in a grid. special navigation key handling * DEFINE CLASS cbogrddropdown AS COMBOBOX HEIGHT = 21 SPECIALEFFECT = 1 STYLE = 2 WIDTH = 75 BORDERSTYLE = 0 *-- Save original setting of _INCSEEK...facilitate incremental searching nOldIncSeek = 0 NAME = "cbogrddropdown" *-- Set to true when the list is dropped so we know how to handle the cursor keys ldroppeddown = .F. *-- Save the original value of the combo when it gets focus uoldval = .F. *-- an array property to hold the rowsource when this is using a rowsourcetype f 5-array DIMENSION acontents[1] *-- Handle the cursor keys differently depending on whether or not the combo is dropped down PROCEDURE handlekey LPARAMETERS nKeyCode LOCAL lnMaxRow, llRetVal WITH THIS *** If escape or enter pressed, the list is not dropped down anymore IF nKeyCode = 27 OR nKeyCode = 13 .ldroppeddown = .F. ENDIF *** If the list is not dropped down, traverse the grid with cursor keys IF !.ldroppeddown WITH .PARENT.PARENT *** Calculate the maximum number of rows in the grid lnMaxRows = INT( ( .HEIGHT - .HEADERHEIGHT - ; IIF( INLIST( .SCROLLBARS, 1, 3 ),; SYSMETRIC( 8 ), 0 ) ) / .ROWHEIGHT ) *** Move up a row in the grid: up arrow key pressed IF nKeyCode = 5 THEN *** If we are sitting on the top row in the visible portion of the grid, *** Scroll the grid up a row in case there is a previous record IF .RELATIVEROW = 1 .DOSCROLL( 0 ) ENDIF .ACTIVATECELL( .RELATIVEROW - 1, .RELATIVECOLUMN ) *** Let KeyPress know we have handled the keystroke llRetVal = .T. ELSE *** Move down a row in the grid if the down arrow key is pressed and the *** combo box is closed *** If we are sitting on the bottom row in the visible portion of the grid, *** Scroll the grid down a row in case there is a next record IF nKeyCode = 24 THEN IF .RELATIVEROW >= lnMaxRows .DOSCROLL( 1 ) ENDIF .ACTIVATECELL( .RELATIVEROW + 1, .RELATIVECOLUMN ) llRetVal = .T. ENDIF ENDIF ENDWITH ENDIF ENDWITH RETURN llRetVal ENDPROC PROCEDURE INIT IF DODEFAULT() THIS.SETUP() ENDIF ENDPROC PROCEDURE GOTFOCUS WITH THIS *** Save Original value in case we have to restore it later .uoldval = .VALUE *** Facilitate incremental searching in the drop down IF VERSION( 5 ) > 699 *** We are in VFP 7.0 or later .noldIncSeek = _INCSEEK _INCSEEK = 1.5 ELSE .noldIncSeek = _DBLCLICK _DBLCLICK = 1.5 ENDIF ENDWITH ENDPROC PROCEDURE CLICK THIS.ldroppeddown = .F. ENDPROC PROCEDURE DROPDOWN THIS.ldroppeddown = .T. ENDPROC PROCEDURE KEYPRESS LPARAMETERS nKeyCode, nShiftAltCtrl IF THIS.handlekey( nKeyCode ) NODEFAULT ENDIF ENDPROC PROCEDURE LOSTFOCUS *** We now need code to check the version number here because VFP 7 *** Does not use _DBLCLICK for Incremental Search IF VERSION( 5 ) > 699 _INCSEEK = THIS.noldIncSeek ELSE _DBLCLICK = THIS.noldIncSeek ENDIF ENDPROC *-- Called from the init() to do any setup work in the combo PROCEDURE SETUP ENDPROC ENDDEFINE * *-- EndDefine: cbogrddropdown **************************************************