Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- TSDWIN: Clipper 5.0 Interface Library - Norton Guide http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]

 twACChoice( nTop, nLeft, nBottom, nRight, aChoices,;
              aLogicals, cUser, nStartItem, nWinRow,;
              lScBar, nTag, cACColor, cBarColor,;
              bPreRun, bPostRun )
 ----------------------------------------------------------------------------

     twACChoice() may be used as a replacement for Clipper's ACHOICE()
     function. twACCHoice() has more flexible control of colour as well
     as built in mouse support. There are also provisions made for
     tagging for multiple choice picklists and function keys are
     assigned to support the tagging operation. A scroll bar may be
     included also if you wish. You may also assign code blocks to
     execute before and after the function operates with PreRun and
     PostRun blocks.

       Key Handling:

         No tagging:

       ESC: Exit without a choice.
     ENTER: Select current item.

         Tagging:

     SPACE: Toggle for tag on highlighted item.
       ESC: Exit without a choice.
     ENTER: Select current item. The array passed must be scanned for
            tags if tagging is allowed. It is important to remember
            that the array is altered by the function if tagging is
            allowed.
        F7: Tag all items.
        F8: Untag all items.
        F9: Swap tagged with untagged items.

     ALPHA: Scans the array for a match and if found the highlight bar
            moves to that item.
        BS: Reset the search string to Null. Any usual cursor
            navigation key also truncates the search string. In this
            version of TSDWIN, the array is scanned for an exact match.

       Mouse Support:

     The mouse operates differently depending on the status of tagging
     defined in the function call.

         No Tagging:

            Left Button: Select current item and exit.
           Right button: Escape with no selection.

         Tagging:

            Left Button: Select current item and exit. The array must
                         be checked for tags on exit.
           Right button: Toggle tag of current item.

         When tagging is in force, there is no provision for exit with
         the mouse. It is customary to define hot spots for the mouse
         to use for exit.

     The above actions only apply when the mouse is in the actual
     browse area. However, the right button can tag wherever it is, if
     tagging is allowed.

     Whenever the mouse cursor is within the browse area, the highlight
     bar follows it. If a navigation key is pressed, the mouse cursor
     follows the highlight bar.

     When the browse is internally configured, two mouse hot spots may
     be defined. The hot spots will cover the area occupied by the
     scrollbars. If scrollbars are allowed, the mouse actions are:

       Vertical Scroll Bar:

         Direction Arrows:

             Left Button: Up or Down one line.
            Right Button: Page Up or Down.
            Both Buttons: Top or Bottom of choice array.

     You may also define your own hot spots to execute code blocks
     during the browse with twACHotSpot().

       Arguments:

     nTop    -+
     nLeft    |- 'N' Screen coordinates for twACChoice() display.
     nBottom  |
     nRight  -+

     aChoices   - 'A' array of character strings to display as menu
                      choices

     aLogicals  - 'A or L' array of logical values which specifies the
                      selectable menu items. If specified as a logical
                      then all items are either available ( .T. ). If
                      nothing is passed, all items are selectable.

     cUser      - 'C' name of a user defined function for handling
                      keystroke exceptions as in Clipper's ACHOICE(),

     nStartItem - 'N' first item to be highlighted when the choices
                      array is displayed.

     nWinRow    - 'N' window row on which the initial choice item
                      appears.

     lScBar     - 'L' logical for scroll bar display.

     nTag       - 'N' numeric indicating the status of tagging:
                          0 - no tagging
                          1 - use TSDWIN default
                          2 - Pretagged array

     cACColor   - 'C' color setting passed as "1,2,,3,4,5". The colours
                      vary according to the type of tagging allowed and
                      whether a logical array is passed. The indexes
                      into the color string are as follows:

                        Array passed:

                      Selectable Untagged items: { 1, 2 }
                        Selectable Tagged Items: { 3, 4 }
                             Unselectable Items: { 5, 5 }

                        TRUE passed:

                      Selectable Untagged items: { 1, 2 }
                        Selectable Tagged Items: { 3, 4 }

                      Therefore, you can have distinct colours for
                      tagged and untagged items for both the normal
                      text and the highlight bar display.

     cBarColor  - 'N' optional scroll bar color. Defaults to the
                      standard color.

     bPreRun    - 'B' Code block to execute before the browse begins.

     bPostRun   - 'B' Code block to execute after the browse ends.

       Return:

     Element number of the item chosen or zero for exit without a
     choice.

       Example:

     FUNCTION Main()
     #include "tsdwin.ch"
     LOCAL wT := 3, wL := 5, wB := 20, wR := 74
     LOCAL ColHead := "", ActionKeys, wColor
     LOCAL wSType := 3, wFType := 4
     LOCAL aTemp :={}, f, nChoice
     LOCAL amArray, nButRow, nButCol, aLogicals
     LOCAL nTop, nLeft, nBottom, nRight, cUser, nStartItem, nWinRow
     LOCAL lScBar, nTag, cACColor, cBarColor

     SETCOLOR( "w+/b,gr+/r,,bg+/n,n/w" )
     twOpen()
     twMouseInit()
     USE Windemo INDEX Windemo
     DO WHILE !EOF()
         AADD( aTemp, Windemo->Codekey + " | " +  Windemo->CodeShort: )
         SKIP
     ENDDO

     twTitle( PADC( "twACChoice() with Tagging", 55 ), "n/w")
     DO WHILE nChoice != 0
         nChoice := twACChoice( twRow( 1 ), twCol( 1 ),;
                                twRow( wB - wT - 1 ), ;
                                twCol( wR - wL - 1 ), aTemp,, ;
                               , 1, 1, .T., 1 )
         twInfo( "You Chose "+ STRINT( nChoice ) + ;
                         IIF( nChoice = 0, '', aTemp[ nChoice ] ))
     ENDDO

     twClear( .F.)
     DO WHILE nChoice != 0
         aTemp :={}
         FOR f = 1 TO 100
                 AADD( aTemp, "Array Element " + STR( f, 3 ) )
         NEXT
         nChoice := twACChoice( twRow( 1 ), twCol( 1 ), ;
                                twRow( wB - wT - 1 ), ;
                                twCol( wR - wL - 1 ), aTemp,, ;
                                , 1, 1, .T., 1 )
         twInfo( "You Chose "+ STRINT( nChoice ))
     ENDDO

     twClear( .F.)
     twTitle( PADC( "twACChoice() with Tagging & Custom Color", 55 ), "n/w")
     nChoice := 1
     DO WHILE nChoice != 0
         aTemp :={}
         FOR f = 1 TO 100
                 AADD( aTemp, "Array Element " + STR( f, 3 ) )
         NEXT
         nChoice := twACChoice( twRow( 1 ), twCol( 1 ),
                                twRow( wB - wT - 1 ), ;
                                twCol( wR - wL - 1 ), aTemp,, ;
                                , 1, 1, .T., 1, ;
                                "w+/b,gr+/r,gr+/b,w+/g,w/b" )
         twInfo( "You Chose "+ STRINT( nChoice ))
     ENDDO

     RETURN NIL

     See more examples in the demo code.

See Also: twACRemHotSpot() twACChoice() twACMouseLine()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson