Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
More than one tab cycle
Message
De
05/08/2006 08:33:17
Hans-Otto Lochmann
Dr. Lochmann Consulting Gmbh
Frankfurt, Allemagne
 
 
À
04/08/2006 17:49:39
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01142829
Message ID:
01143193
Vues:
12
Hi Hilmar,
Hi Dragan,

>> ...
>>I want to some generic solution, which will work in VFP 9 and up. Unfortunately the When event does not >> ...
>How about GotFocus() instead of When()? I am not sure if this one will allow a SetFocus(), but you can try.
>
>I guess the idea is for When() to execute before an object obtains the focus ("Am I allowed to receive the focus?"), and GotFocus(), after it receives the focus.

A very good idea. I tried it yesterday but it didn't work, because when you set Visible = .F. for any object, it does not get the focus. But a I found out today, the When event does not work either if Visible is set .F. So your proposal made me thinking again, because I by using the When event I have the additional effect to avoid to use the Timer object at all. So I finally came up with a rather simple solution.

In order to have Visible = .T. and in spite of that have the object to be "invisible" I just set Width and Height equal 0. It works!

You will find my present idea for the special CommandButton class further down.

The next step then will be to incorporate Dragan's idea to enumerate the objects with a TabIndex and how to use that to address objects by their tab order. This then could lead to some kind of an automatism to fill out the NextObject and PreviousObject properties of the two required instances of my CommandButton class. I also assume, that this then will require to put all object into an container and have that "automated procedure" to be run in the Init event of that container. Well, this work will be left to some time later.

Again many thanks to everybody.

Greetings

Hans
**************************************************
*-- 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
**************************************************
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform