PRB: Valid Clause Not Executed When Leaving ObjectLast reviewed: April 30, 1996Article ID: Q124921 |
The information in this article applies to:
SYMPTOMSWhen the insertion point is positioned on a popup or a list box, and then the user clicks some other object, such as a push button, code contained in the VALID clause of the popup is not executed.
CAUSEVALID clauses are executed under two conditions: - When a user attempts to leave a field.
-or-- When a user selects an item from a screen object. In the latter case, the VALID clause is not executed in either a list box or popup object, because tabbing out of the object or clicking another object on the screen does not constitute leaving an object. When an element is chosen from either of these objects, only then is the VALID clause code executed. Although this may seem counter-intuitive, logically this makes sense because tabbing through a list box or popup isn't the same action as selecting an item from the list.
WORKAROUNDTo enforce the execution of Valid routines for objects like a list box or a popup, regardless of whether or not an item was chosen, use a flag to determine if the valid has been executed. The following steps explain how to do this. This example assumes that the VALID clause of the list box or popup calls a user defined procedure or function, such as listbox_valid().
STATUSThis behavior is by design.
MORE INFORMATION
Steps to Reproduce ProblemCreate and run a program containing the following code:
DEFINE WINDOW "test" ; AT 0.000, 0.000 ; SIZE 15.615,91.400 ; FONT "MS Sans Serif", 8 ; FLOAT ; NOCLOSE ; MINIMIZE ; SYSTEM CLOSE ALL USE SYS(2004)+"\Tutorial\Customer" IN 1 SELECT company FROM customer INTO ARRAY testarray ACTIVATE WINDOW test NOSHOW @ 1.846,19.200 GET popval ; PICTURE "@^" ; FROM testarray ; SIZE 1.538,25.167 ; DEFAULT 1 ; FONT "MS Sans Serif", 8 ; STYLE "B" ; VALID myvalid1() @ 2.423,50.800 GET m.test ; SIZE 1.000,23.200 ; DEFAULT " " ; FONT "MS Sans Serif", 8 ; PICTURE "@K" ; VALID myvalid2() @ 4.692,19.400 GET listval ; PICTURE "@&N" ; FROM testarray ; SIZE 6.615,55.200 ; DEFAULT 1 ; FONT "MS Sans Serif", 8 ; VALID myvalid3() @ 12.000,19.400 GET butnval ; PICTURE "@*HN Test Button 1;Test Button 2;Quit" ; SIZE 1.769,15.000,0.667 ; DEFAULT 1 ; FONT "MS Sans Serif", 8 ; STYLE "B" ; VALID myvalid4() ACTIVATE WINDOW test READ CYCLE RELEASE WINDOW test ****************[ VALID FUNCTIONS ]**************** FUNCTION myvalid1 && Popval VALID WAIT WINDOW "Executing popup Valid routine." FUNCTION myvalid2 && m.test VALID WAIT WINDOW "Executing GET field VALID routine." FUNCTION myvalid3 && ListVal VALID WAIT WINDOW "Executing list box VALID routine" FUNCTION myvalid4 && ButnVal VALID DO CASE CASE butnval = 1 WAIT WINDOW "Pressed button 1" CASE butnval = 2 WAIT WINDOW "Pressed button 2" CASE butnval = 3 CLEAR READ ENDCASE |
Additional reference words: VFoxWin 3.00 FoxWin 2.50 2.50a 2.50b 2.60 2.60a
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |