PDA

View Full Version : Making a false entry_state on a (db)Form work correctly



Allan Greis Eriksen
25-Mar-2015, 05:09 PM
If you set a (db)Forms entry_state to false you can place the cursor inside the form but you can not enter any data. The current value will not change if you try to key in new data. That is to be expected from a disabled entry_state. The function keys and such should still work and they do so no problem here either. However there are a couple of keys that do change the content when it shouldn't.

The keys in question are:

Backspace
Delete


Try adding this form to a testview, compile, run and then place the cursor in the middle of the value. Then hit the <Delete> key or the <Backspace> key. As you can see they both changes the current value of the form.

Object oForm1 is a Form
Set Size to 13 100
Set Location to 60 111
Set Entry_State to False

Procedure Activating
Forward Send Activating
Set Value to "123456789"
End_Procedure

End_Object

Say you have a prompt list for the form so you give the user a selection list to choose from. They should not be able to enter the value directly so the new value has to be selected from the selection list. But how do the user then clear the value if he want it to be empty. The current workings of the form can leave a half-deleted value that you have to code some sort of validation against. Did the user intend to delete the value or change the value and found out he couldn't?

This is a workaround for the offending keys. Place it in a subclass of a form and dbform.


Procedure Key Integer iKeyValue Returns Integer
Integer iRetVal
Boolean bEntryState bForwardKey
Move True to bForwardKey
Get Entry_State to bEntryState
If (bEntryState = False) Begin
If (iKeyValue = 277) Begin // Delete key
Move False to bForwardKey
Send OnClearForm
End
Else If (iKeyValue = 278) Begin // Back-space
Move False to bForwardKey
Send OnClearForm
End
End
If bForwardKey Begin
Forward Get msg_Key iKeyValue to iRetVal
End
Procedure_Return iRetVal
End_Procedure


{MethodType = Event}
Procedure OnClearForm
End_Procedure



Note that I have added an OnClearForm event that fires when the user try to delete the value. With the workaround you can have the user hit the <Delete> key or the <Backspace> key in order to call the OnClearForm event. You can then override the method in your form object to have it clear the form or do whatever manually related stuff you have coded for the form.

I know this is both a workaround and a bug report. That is the beauty of fixing errors. You begin to add new stuff along the way ;)

Jim Albright
26-Mar-2015, 11:40 AM
What happens when you add "Set Enabled_State to False"?

Garret Mott
28-Mar-2015, 12:31 PM
The problem with that is that you can't use the field for finding or copying.

Jim Albright
28-Mar-2015, 12:35 PM
Not our problem. The files will be turned over to the police. It will be up to them to search, if need be.:cool:

Garret Mott
29-Mar-2015, 07:17 AM
The NSA already has 'em I bet!

Dennis Piccioni
14-Apr-2015, 02:34 PM
Hi Allan,

logged as bug # 6810.

I also reviewed and updated the rather dated help for Entry_State and Enabled_State.

erikzcai
15-Apr-2015, 11:16 AM
While we are on this...

The decimal point key always types into the the form when the entry_state is false. Procedure Key reports the key value as ZERO.

Erik

Dennis Piccioni
15-Apr-2015, 11:44 AM
Thank Erik, I added that to the bug report.