Jill,
>I remember there being some problem using the Default property set to .T. on a button....I'm not sure if that could be related to your problem or not...did
Yes, this was a huge problem and the only solution, which I finally came up, was to put in textbox KeyPress method this code: (and eliminate Valid code)
LPARAMETERS nKeyCode, nShiftAltCtrl
local lcValue
lcValue=alltrim(this.value)
if nKeyCode=13
with this.parent.parent
.Validate(lcValue)
if .AllowAdd
.Container1.AddRemove1.cmdAdd.Click()
endif
endwith
nodefault
endif
The similar code in Valid event didn't work, as I wanted...
you convince yourself that returning a .F. from a Valid will not let you out, even w/mouse actions? J
Yes, I tested this and convinced myself. Thanks.
>>Jill,
>>
>>I'm really messed up :( I have a class, which allows me to add values, if they are not duplicates. This is exactly what I have in textbox.valid method:
>>
>>
>>********************************************************************
>>* Description.......: Text1.Valid
>>* Calling Samples...:
>>* Parameter List....:
>>* Created by........: Nadya Nosonovsky 03/07/2000 03:20:36 PM
>>* Modified by.......: Nadya Nosonovsky 03/07/2000 04:57:47 PM
>>********************************************************************
>>local lcValue
>>lcValue=alltrim(this.value)
>>with this.parent.parent
>> .AllowAdd=.f.
>> .Validate(lcValue)
>> if .AllowAdd
>> .AddValue(lcValue)
>> this.parent.list1.Requery()
>> this.value=''
>> endif
>>endwith
>>return this.parent.parent.AllowAdd
>>
>>
>>The problem is that I have Ok button on the form with Default property set to .T.
>>So, each time, I hit Enter, this form finishes it's work. I tried NoDefault in KeyPress, but now it doesn't work the way I want.
>>
>>>That is exactly my situation...the system is a reservation system and I want to get the number of reservations before anything else happens...I could do this in a number of ways, of course, but right now I'm using a textbox on the form that checks the value and does not allow focus to leave the textbox until they enter a valid value - except if they ESCAPE out. They can't click on a combo, or anything else, except CANCEL button.
>>>
>>>J
>>>
>>>> My point actually was, that even if the control TabOrder is 1 on the form and this control has something in Valid method, we still can leave this control and go to another with mouse. Right now, however, I'm not so sure in this statement, so I need to make additional testing. At least, I noticed this behavior in some of my classes...
If it's not broken, fix it until it is.
My Blog