home *** CD-ROM | disk | FTP | other *** search
- * This is where most of the missing functionality is restored
- * to VFP's rather deficient combo box
- LPARAMETERS lnKeyCode, nShiftAltCtrl
-
- Local lcOldDisplayValue, llVisibleChar
-
- * If the control is a Drop-Down Combo (text box with list)
- * and the control is set for incremental searching as the user types
- if this.Style = 0 and this.IncrementalSearch
- llVisibleChar = .F. && Assume a non-visible character
- lcOldDisplayValue = this.DisplayValue && Save away current value
-
- DO CASE
- * Valid chars include letters, digits, spaces, and apostrophes
- CASE BETWEEN(lnKeyCode, 65, 90);
- OR BETWEEN(lnKeyCode, 97, 122);
- OR BETWEEN(lnKeyCode, 48, 57);
- OR INLIST(lnKeyCode, 32, 39)
- this.SearchKey = this.SearchKey + CHR(lnKeyCode)
- llVisibleChar = .T.
-
- * Backspace - remove the last character
- CASE lnKeyCode = 127
- IF LEN(this.SearchKey) > 0
- this.SearchKey = LEFT(this.SearchKey,;
- LEN(this.SearchKey) - 1)
- ENDIF
-
- * Delete - get rid of the current entry
- CASE lnKeyCode = 7
-
- * Up Arrow - go to previous item in list
- CASE lnKeyCode = 5
- this.ListIndex = max(this.ListIndex - 1, 1)
- this.SearchKey = ""
- lcOldDisplayValue = this.DisplayValue
-
- * Down Arrow - go to next item in list
- CASE lnKeyCode = 24
- this.ListIndex = min(this.ListIndex + 1, this.ListCount)
- this.SearchKey = ""
- lcOldDisplayValue = this.DisplayValue
-
- * Any other key - do nothing at all
- OTHERWISE
- RETURN
- ENDCASE
-
- * Don't automatically let key press enter combo box
- NODEFAULT
-
- * If we have a SearchKey, find it
- IF NOT EMPTY(this.SearchKey)
- this.ListIndex = This.ListFind(this.SearchKey)
- ENDIF
-
- * If we don't have a SearchKey, or it wasn't found
- IF EMPTY(this.SearchKey) OR this.ListIndex = 0
- * If we're not limiting the typed value to list items
- IF NOT this.LimitToList
- this.DisplayValue = this.SearchKey
- this.SelLength = 0
- ELSE
- * Do not add char just typed to search string
- this.SearchKey = LEFT(this.SearchKey,;
- LEN(this.SearchKey) - 1)
- this.DisplayValue = lcOldDisplayValue
-
- if this.BeepOnError and llVisibleChar
- ?? CHR(7)
- endif
- ENDIF
- ELSE
- * Set the new value to the item found in the list
- this.DisplayValue = trim(this.list(this.ListIndex))
- ENDIF
-
- * Select the text in the control
- this.SelStart = LEN(this.SearchKey)
- this.SelLength = LEN(this.DisplayValue)
- endif
-
- * Update the underlying control source
- this.UpdateControlSource
-