oWnd:bKeydown does not trigger when DEL key pressed
oWnd:bKeydown does not trigger when DEL key pressed
I want to have a save button activate when changes are made to fields on window.
The line below works for most keys, but the Delete and Back keys are ignored.
::oWnd:bKeyDown = { | nKey | if( ! self:lSave .and. (( nKey > 31 .and. nKey < 223) .or. nKey = VK_BACK .or. nKey = VK_DELETE), self:togglesave(), ) }
Is there another (easier) way to detirmine if control changes?
The line below works for most keys, but the Delete and Back keys are ignored.
::oWnd:bKeyDown = { | nKey | if( ! self:lSave .and. (( nKey > 31 .and. nKey < 223) .or. nKey = VK_BACK .or. nKey = VK_DELETE), self:togglesave(), ) }
Is there another (easier) way to detirmine if control changes?
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
In both cases you can do something similar to this:
EMG
Code: Select all
FOR i = 1 TO LEN( oDlg:aControls )
IF oDlg:aControls[ i ]:ClassName() = "TGET"
oDlg:aControls[ i ]:bLostFocus = ...
ENDIF
NEXT
- James Bott
- Posts: 4654
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
Gale,
If you are using TDatabase (or TData) there is a method Modified() that checks the buffer data (in aBuffer) against the data on the disk to see if there have been any changes.
If you are not using TDatabase, then you can store a copy of all the data in the dialog in an array before the edit, then check it against the array after. This, of course, requires more hand coding which may not be feasible if you have a lot of controls and/or a lot of dialogs.
This is one very good reason (of many) to be using database objects.
James
If you are using TDatabase (or TData) there is a method Modified() that checks the buffer data (in aBuffer) against the data on the disk to see if there have been any changes.
If you are not using TDatabase, then you can store a copy of all the data in the dialog in an array before the edit, then check it against the array after. This, of course, requires more hand coding which may not be feasible if you have a lot of controls and/or a lot of dialogs.
This is one very good reason (of many) to be using database objects.
James
using bChange does not work either. When backspace or delete key pressed the bChange is not getting fired.
Here is routine I use
FOR nCounter := 1 TO LEN( oDlg:aControls )
IF oDlg:aControls[ nCounter ]:ClassName() = "TGET" .or. oDlg:aControls[ nCounter ]:ClassName() = "TCHECKBOX"
if oDlg:aControls[ nCounter ]:bChange == nil
// tracelog( oDlg:aControls[ nCounter ]:ClassName() )
oDlg:aControls[ nCounter ]:bChange = { || ::togglesaveon() }
endif
ENDIF
NEXT
I verified with tracelog that proper controls were getting bChange assigned.
Here is routine I use
FOR nCounter := 1 TO LEN( oDlg:aControls )
IF oDlg:aControls[ nCounter ]:ClassName() = "TGET" .or. oDlg:aControls[ nCounter ]:ClassName() = "TCHECKBOX"
if oDlg:aControls[ nCounter ]:bChange == nil
// tracelog( oDlg:aControls[ nCounter ]:ClassName() )
oDlg:aControls[ nCounter ]:bChange = { || ::togglesaveon() }
endif
ENDIF
NEXT
I verified with tracelog that proper controls were getting bChange assigned.
James,
I am trying to add a save button that shows when a change is made.
I use tdatabase but that only works when you check it.
If you change a get then tab to next get there is no visable indication data has changed. I was just wanting a button that would activate showing the user that changes have been made and a save is necessary.
I am trying to add a save button that shows when a change is made.
I use tdatabase but that only works when you check it.
If you change a get then tab to next get there is no visable indication data has changed. I was just wanting a button that would activate showing the user that changes have been made and a save is necessary.
- James Bott
- Posts: 4654
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
Gale,
I just had an idea how you can test for changes without much code even if you are not using TDatabase.
At the start of the dialog using the ON INIT clause call something like this:
Then at the end, use something similar to check for changes.
James
I just had an idea how you can test for changes without much code even if you are not using TDatabase.
At the start of the dialog using the ON INIT clause call something like this:
Code: Select all
...on init originalData( oDlg )
function originalData( oDlg )
local i:=0, aBuffer:={}
for i = 1 to len( oDlg:aControls )
aadd( aBuffer, oDlg:aControls[i] )
next
return aBuffer
James
Sorry, I forgot to add my folders on a for next loop
FOR nCounter := 1 TO LEN( oFld:aDialogs[ 1 ]:aControls )
IF oFld:aDialogs[ 1 ]:aControls[ nCounter ]:ClassName() = "TGET" .or. oFld:aDialogs[ 1 ]:aControls[ nCounter ]:ClassName() = "TCHECKBOX"
if oFld:aDialogs[ 1 ]:aControls[ nCounter ]:bChange == nil
tracelog( oFld:aDialogs[ 1 ]:aControls[ nCounter ]:ClassName() )
oFld:aDialogs[ 1 ]:aControls[ nCounter ]:bChange = { || ::togglesaveon() }
endif
ENDIF
NEXT
It is working generally. I may have to change it to your suggestion using bLostFocus and adding a check for oDbf:modified().
Sometimes the backspace or delete keys trigger bChange even though nothing is changed.
FOR nCounter := 1 TO LEN( oFld:aDialogs[ 1 ]:aControls )
IF oFld:aDialogs[ 1 ]:aControls[ nCounter ]:ClassName() = "TGET" .or. oFld:aDialogs[ 1 ]:aControls[ nCounter ]:ClassName() = "TCHECKBOX"
if oFld:aDialogs[ 1 ]:aControls[ nCounter ]:bChange == nil
tracelog( oFld:aDialogs[ 1 ]:aControls[ nCounter ]:ClassName() )
oFld:aDialogs[ 1 ]:aControls[ nCounter ]:bChange = { || ::togglesaveon() }
endif
ENDIF
NEXT
It is working generally. I may have to change it to your suggestion using bLostFocus and adding a check for oDbf:modified().
Sometimes the backspace or delete keys trigger bChange even though nothing is changed.
- James Bott
- Posts: 4654
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact: