I was unable to find valid clauses while inputting data in TextBoxes used to validate input data, like in Clipper.
Doesn't this exists in HMG3 ?
Or am I missing something ?
Valid clause while inputting data
Moderator: Rathinagiri
Valid clause while inputting data
[[]] Mauricio Ventura Faria
- Rathinagiri
- Posts: 5471
- Joined: Tue Jul 29, 2008 6:30 pm
- DBs Used: MariaDB, SQLite, SQLCipher and MySQL
- Location: Sivakasi, India
- Contact:
Re: Valid clause while inputting data
There are no valid clauses in HMG3, however we can use ONLOSTFOCUS event and SETFOCUS method to validate the textboxes.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
South or North HMG is worth.
...the possibilities are endless.
Re: Valid clause while inputting data
Since you are posting in HMG4 forum I suppose you are working with version 4.concentra wrote:I was unable to find valid clauses while inputting data in TextBoxes used to validate input data, like in Clipper.
Doesn't this exists in HMG3 ?
Or am I missing something ?
I already wrote some basic code for VALID, well, 2 versions of it.
In the first version, the background color of the invalid fields is red. You can move to ANY field in ANY order... you have full movement possibilities. This is how a full gui application should behave. Unfortunately porting code from old clipper sources requires we have full control on VALID: the user is not allowed to exit the valid until the content is right...
So the second version uses onLostFocus. You need to use a recent version of Harbour (see hmg4 changelog) and change the final code of Textbox:ProcessTextBoxLostFocus in
Code: Select all
IF ValType( ::bOnLostFocus ) != 'U'
ret := eval( ::bOnLostFocus )
if valtype( ret ) != "L"
ret := .T.
endif
ENDIF
if ! ret
::setFocus()
return .T.
endif
::lLostFocusExecFlag := .F.
RETURN .F.
Unfortunately, it seems that this setFocus generates a FocusOut event from the widget that should get focus and it may create a loop... it must be handled....
Actually, instead of using events it would be better to use subclassing... some c++ samples I found report that they behave correctly and it may solve our problems...
Subclassing c++ means that:
- this special class is added to Harbour (so hmg4 users that want to recompile hmg4 can do it normally)
- this special class is added to HMG4 directly (this requires hmg4 users that want to recompile hmg4 to install Qt SDK and add a directory to the PATH environment variable)
I prefer the second way...
Re: Valid clause while inputting data
Yes I am.mrduck wrote:Since you are posting in HMG4 forum I suppose you are working with version 4.
I questioned the existence in HMG3 because in FiveWin I use this a lot.
This seems to be what I need.I already wrote some basic code for VALID, well, 2 versions of it.
In the first version, the background color of the invalid fields is red. You can move to ANY field in ANY order... you have full movement possibilities. This is how a full gui application should behave. Unfortunately porting code from old clipper sources requires we have full control on VALID: the user is not allowed to exit the valid until the content is right...
So the second version uses onLostFocus. You need to use a recent version of Harbour (see hmg4 changelog) and change the final code of Textbox:ProcessTextBoxLostFocus in
This code IS NOT fully tested and may have some problems. It uses a FocusOut event, calls the "valid" codeblock and then if the codeblock returns .F. it calls a setFocus() to regain focus.Code: Select all
IF ValType( ::bOnLostFocus ) != 'U' ret := eval( ::bOnLostFocus ) if valtype( ret ) != "L" ret := .T. endif ENDIF if ! ret ::setFocus() return .T. endif ::lLostFocusExecFlag := .F. RETURN .F.
Unfortunately, it seems that this setFocus generates a FocusOut event from the widget that should get focus and it may create a loop... it must be handled....
I will do some testing and will put results here.
This seems a little to much to me now. I have very few skills in C ...Actually, instead of using events it would be better to use subclassing... some c++ samples I found report that they behave correctly and it may solve our problems...
Subclassing c++ means that:
- this special class is added to Harbour (so hmg4 users that want to recompile hmg4 can do it normally)
- this special class is added to HMG4 directly (this requires hmg4 users that want to recompile hmg4 to install Qt SDK and add a directory to the PATH environment variable)
I prefer the second way...
[[]] Mauricio Ventura Faria
Re: Valid clause while inputting data
Francesco,
This shared var is settled true whenever a ProcessXxxxLostFocus HMG4 event is started and settled false when finished.
And when another ProcessXxxxLostFocus HMG4 event is started before the current one finishes, it verify this flag and, if it settled, abandon processing.
This potential loop situation can be handled by a shared var, and yes, I now this isn't the most elegant solution.mrduck wrote:This code IS NOT fully tested and may have some problems. It uses a FocusOut event, calls the "valid" codeblock and then if the codeblock returns .F. it calls a setFocus() to regain focus.
Unfortunately, it seems that this setFocus generates a FocusOut event from the widget that should get focus and it may create a loop... it must be handled....
This shared var is settled true whenever a ProcessXxxxLostFocus HMG4 event is started and settled false when finished.
And when another ProcessXxxxLostFocus HMG4 event is started before the current one finishes, it verify this flag and, if it settled, abandon processing.
[[]] Mauricio Ventura Faria
Re: Valid clause while inputting data
Please try AND NOT commit movingconcentra wrote: This shared var is settled true whenever a ProcessXxxxLostFocus HMG4 event is started and settled false when finished.
And when another ProcessXxxxLostFocus HMG4 event is started before the current one finishes, it verify this flag and, if it settled, abandon processing.
Code: Select all
::lLostFocusExecFlag