************************************************** *-- Class: cmdBouncingButtons (c:\dev\vfp\tests\testtaborder\libtaborderv4.vcx) *-- ParentClass: ccommandbutton (c:\dev\vfp\tests\testtaborder\libtaborderv4.vcx) *-- BaseClass: commandbutton *-- Time Stamp: 08/05/06 01:51:07 PM * DEFINE CLASS cmdBouncingButtons AS cCommandButton Height = 27 Width = 27 Caption = "F/B" cnextobjectname = "" cpreviousobjectname = "" Name = "cmdbouncingbuttons" PROCEDURE about ******************************************************************************** *-- Project........: General Purpose *-- ClassName......: cmdBouncingButtons *-- BaseClass......: CommandButton *-- Purpose........: To be both corners of a group of objects, which will keep *-- the focus within this group. *-- Author.........: Dr. Hans-Otto Lochmann *-- Copyright......: (c) 2006; Dr. Lochmann Consulting GmbH. *-- Freeware. You can use it "as is" at your own risk. *-- No warranty or liability whatsoever. *-- Version........: 1.00 *-- First created..: Aug. 05, 2006 *-- Last Update....: ******************************************************************************** *-- *-- Purpose (detailed). *-- *-- Sometimes it is advisable to group several objects into a group, which *-- keeps the focus within this group. *-- Example 1: *-- You may have a small modal window, which is used to enter some data and *-- you want to validate the entries in the last TextBox before the Enable *-- property of the OK-Button can be set. *-- Example 2: *-- You may have a form with many TextBoxes, which belong to different *-- logical aspects of a logical entity, like all data of a company. You *-- may like to have a separate "TabCycleGroup" for *-- - all data about name, address etc, *-- - all data about its financial structure etc, *-- - all data about the activities with this company etc, *-- in one window. (An alternative way to group these data may be to put *-- them onto several pages of a PageFrame). *-- *-- Usage. *-- *-- 1. Place two instances of this class onto a form, a container or whatever *-- contains the entry TextBoxes, one pair for each one group of objects, *-- which will be the member of a "TabCycleGroup" *-- 2. Set the tab order of each object in such a group so, *-- - that all members of this group are in a consecutive sequence of tab *-- orders like e.g. 1 to 10 or 15 to 22 without any gap inbetween, *-- - that one the instances of this class is the first in this group *-- and the other one the last one. *-- 3. Fill out the properties cNextObjectName and cPreviousObjectName with *-- the name of the next object and of the previous object. *-- 4. Repeat this for each "TabCycleGroup". *-- ******************************************************************************** ENDPROC PROCEDURE Init With This As This *-- Check reference objects. If Empty( .cNextObjectName ) Assert .F. Message 'this.cNextObjectName must be defined!' Endif Empty( .cNextObjectName ) If Empty( .cPreviousObjectName ) Assert .F. Message 'this.cPreviousObjectName must be defined!' Endif Empty( .cPreviousObjectName ) *-- As this does not work, if this is made invisible, this is made *-- "difficult to spot". .Height = 0 .Width = 0 Endwith ENDPROC PROCEDURE GotFocus Local lnLastKeyEntered As Integer LOCAL lcCommand as String m.lnLastKeyEntered = Lastkey() && Needed if Set Step On is issued later. With This As This *-- Process the last keystroke. Do Case Case Inlist( m.lnLastKeyEntered, 4, 9, 13, 24, 148) *-- Forward - If the last key entered is either *-- arrow right, tab, enter, down arrow, ctrl-tab, *-- then we jump to the corresponding button at the beginning of the group. m.lcCommand = .cNextObjectName + '.SetFocus()' .Parent.&lcCommand. Return Case Inlist( m.lnLastKeyEntered, 5, 15, 19, 165) *-- Backward - If the last key entered is either *-- up arrow, back tab, left arrow, ctrl-backtab, *-- then we jump to the corresponding button at the end of the group. m.lcCommand = .cPreviousObjectName + '.SetFocus()' .Parent.&lcCommand. Return Endcase Endwith ENDPROC ENDDEFINE * *-- EndDefine: cmdbouncingbuttons **************************************************