Strange behaviour of LastKey()
Posted: Sun Feb 18, 2007 2:08 pm
Hello,
I noticed that LastKey() has a strange behaviour.
This is my code :
-------------------------------------
PRIVATE Niv := 1
DEFINE DIALOG DiaDlg NAME "DIALOG"
REDEFINE oGET1 VAR FIELD1 ID 101 OF DiaDlg PICTURE "XXX"
...
REDEFINE oGET9 VAR FIELD9 ID 109 OF DiaDlg PICTURE "XXX"
REDEFINE BUTTON ID 200 OF DiaDlg ACTION(Niv:=9,DiaDlg:End())
REDEFINE BUTTON ID 201 OF DiaDlg ACTION(Niv:=0,DiaDlg:End())
ACTIVATE DIALOG DiaDlg CENTERED
IF LastKey() = VK_ESCAPE ; Niv := 0 ; ENDIF
-------------------------------------
What do I want to do ?
Button 200 is a button "Save"
Button 201 is a button "Quit"
If niv = 9, the data will be saved. If niv = 0, the program will check whether there is a difference between the data on the screen and the data on disk. If all the data are the same, the procedure will be ended, otherwise the user will be asked if he is sure that the data will not be saved.
I want that the user also can use the Escape-key which has to behave like the button "Quit".
So, If the user clicks "Quit", niv = 0 but also if the Escape-key is pressed, niv = 0.
But what is happening ?
Once I have pressed the Escape-key, lastkey() keeps positioned on the Escape-key. If button "Save" is clicked the next time, the program will always act as if the Escape-key has been pressed.
I added the test : MsgInfo(LastKey()). It always returns (27 = Escape), even it the lastkey wasn't the Escape-key at all.
Can anyone tell me what's wrong ?
Thank you very much in advance for any help.
Michel
I noticed that LastKey() has a strange behaviour.
This is my code :
-------------------------------------
PRIVATE Niv := 1
DEFINE DIALOG DiaDlg NAME "DIALOG"
REDEFINE oGET1 VAR FIELD1 ID 101 OF DiaDlg PICTURE "XXX"
...
REDEFINE oGET9 VAR FIELD9 ID 109 OF DiaDlg PICTURE "XXX"
REDEFINE BUTTON ID 200 OF DiaDlg ACTION(Niv:=9,DiaDlg:End())
REDEFINE BUTTON ID 201 OF DiaDlg ACTION(Niv:=0,DiaDlg:End())
ACTIVATE DIALOG DiaDlg CENTERED
IF LastKey() = VK_ESCAPE ; Niv := 0 ; ENDIF
-------------------------------------
What do I want to do ?
Button 200 is a button "Save"
Button 201 is a button "Quit"
If niv = 9, the data will be saved. If niv = 0, the program will check whether there is a difference between the data on the screen and the data on disk. If all the data are the same, the procedure will be ended, otherwise the user will be asked if he is sure that the data will not be saved.
I want that the user also can use the Escape-key which has to behave like the button "Quit".
So, If the user clicks "Quit", niv = 0 but also if the Escape-key is pressed, niv = 0.
But what is happening ?
Once I have pressed the Escape-key, lastkey() keeps positioned on the Escape-key. If button "Save" is clicked the next time, the program will always act as if the Escape-key has been pressed.
I added the test : MsgInfo(LastKey()). It always returns (27 = Escape), even it the lastkey wasn't the Escape-key at all.
Can anyone tell me what's wrong ?
Thank you very much in advance for any help.
Michel