home *** CD-ROM | disk | FTP | other *** search
- /*
- Listing 25.6. A general-purpose browse cursor navigation function.
- Author: Craig Yellick
- Excerpted from "Clipper 5: A Developer's Guide"
- Copyright (c) 1991 M&T Books
- 501 Galveston Drive
- Redwood City, CA 94063-4728
- (415) 366-3600
- */
-
- #include "inkey.ch"
-
- function Navigate(b, k)
- /*
- Establish array of navigation keystrokes and the cursor
- movement method to associate with each key. The array is
- comprised of two-element arrays containing the inkey() value
- of the key and a codeblock to execute when the key is pressed.
-
- This function gets passed a browse object and a potential
- navigation key. If the key is found in the array its
- associated navigation message is sent to the browse. Function
- returns .t. if navigation was handled, .f. if not.
- */
- local n
-
- // Made static so it doesn't get re-initialized on every call.
- static keys_
- if keys_ = nil
- keys_ := { ;
- {K_UP, {|| b:up() }},; // Up one row
- {K_DOWN, {|| b:down() }},; // Down one row
- {K_LEFT, {|| b:left() }},; // Left one column
- {K_RIGHT, {|| b:right() }},; // Right one column
- {K_PGUP, {|| b:pageUp() }},; // Up on page
- {K_PGDN, {|| b:pageDown()}},; // Down one page
- {K_CTRL_PGUP,{|| b:goTop() }},; // Up to the first record
- {K_CTRL_PGDN,{|| b:goBottom()}},; // Down to the last record
- {K_HOME, {|| b:home() }},; // First visible column
- {K_END, {|| b:end() }},; // Last visible column
- {K_CTRL_HOME,{|| b:panHome() }},; // First column
- {K_CTRL_END, {|| b:panEnd() }},; // Last column
- {K_TAB, {|| b:panRight()}},; // Pan to the right
- {K_SH_TAB, {|| b:panLeft() }} ; // Pan to the left
- }
- endif
-
- // Search for the inkey() value in the cursor movement array.
- // If one is found, evaluate the code block associated with it.
- // Remember these are paired in arrays: {key, block}.
- //
- n := ascan(keys_, { | pair | k == pair[1] })
- if n <> 0
- eval(keys_[n, 2])
- endif
-
- return (n <> 0)
-
- // end of file CHP2506.PRG
-