At first I was contrary since it is against GUI standards... you can't be forced on a field if there are other active fields on the form.
Then he convinced me saying that also my harbour text-mode code heavily relies on VALIDs and their side-effect (f.e. record pointer moves).
It is not easy to do in Qt, just because it is not standard GUI behaviour ! And Qt doesn't ask "I want to leave the object, can I ?" It just moves the focus and generates events and signals...
Well, I must advise you that using the HMG3 way to use :setFocus() inside a onLostFocus event may not work in HMG4 ! :setFocus() can't be used safely in the lost focus event.
So I used a little trick: keep record of the object losing focus with a VALID not true and on the onGotFocus of the next textbox check if we must give focus back to someone else...
Up to now it seems to work in a very simple, little test, with only a widget in the form with a VALID... The test must be expanded to accomodate several other complex situations... (I already know that current code can fail in some cases...)
From samples\hardvalid\demo_1.prg
Code: Select all
With Object o2 := textbox():New()
:Value := 'must be PIPPO'
// :onValid := {|| o2:value == "PIPPO" }
:onValid := {|| hb_QWith():value == "PIPPO" }
:tooltip := "You must enter <b>PIPPO</b> to move from this textbox"
End With
- started using of HB_TRACE for helping debugging... this is absolutely transparent to library users since the trace must be enabled during library compilation...
- started to add some docs in the code to explain what that code does... too much time spent to guess what a piece of code written a month ago actually does...
- introduced calling a code block nested in a WITH OBJECT Self
Code: Select all
WITH OBJECT Self; ret := eval( ::bOnValid ); END
I still think that hard valids are not GUI standard and they are BAD... I know that committed code needs to be updated for handling more complex cases... I already know how to visually signal that a textbox has invalid value (via css selectors - great Qt power !!!)
Now I ask you to report your ideas on this feature.