Dear Antonio, James, Uwe and friends!!
How, after pressed ESC, I can set the last key pressed to another, or simply, cancel your execution?
JĂșlio CĂ©sar M. Ferreira
FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
Dear Antonio, James, Uwe and friends!!
How, after pressed ESC, I can set the last key pressed to another, or simply, cancel your execution?
Somebody knows?
Exists any way to do?
Julio,
>How, after pressed ESC, I can set the last key pressed to another, or simply, cancel your execution?
I am not sure what you are asking. Can you explain in more detail, maybe with an example?
James
James,
Thanks for you answer!
In determinate screen of my system, when the user press the key and if this key is escape, I want to cancel this pressed key... like setLastKey(0) of clipper. This is into a get!
Regards,
Michel D.
Genk (Belgium)
I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773
Julio and Michel,
>In determinate screen of my system, when the user press the key and if this key is escape, I want to cancel this pressed key... like setLastKey(0) of clipper. This is into a get!
This is not standard windows behavior. When the user is typing into a GET and they press the escape key, the dialog should close without saving the data. This is standard windows behavior.
If you wish to do something non-standard, then you should have a REALLY good reason for it as ALL users will be confused by it.
I was the one that asked for lastKey() to be added to FW many years ago. It was needed to process oGet:bChange since the last key typed wasn't in the GET buffer when bChange was eval'd. This has turned out to be a continuous issue since then due to the confusion about it.
Lastkey() was only designed to be used with GETs and only for that purpose. It does not contain the last key typed anywhere in the application. It was (originally) code added only to the TGet class. I don't know if it has been added to other classes since then. You can see the problem, all the FW source code would have to be read and evaluated for the addition of lastkey processing. Personally, I do not think this would be worth the effort. I have never found the need for the use of lastkey() except with the GET and even that is not needed now since we now have oGet:bPostEdit which does contain that lastkey typed.
From your description of the behavior you want, it sounds like you just need to use the backspace key. That "cancels" the last key typed.
Regards,
James
James,
You remember my topic about the incremental search when click any header of a xbrowse?
So, I need this solution because when the user is typing into a get and press the escape key, it closes the dialog and I want only that closes the object get!
LOCAL cGET1 := SPACE(10)
LOCAL cGET2 := SPACE(10)
LOCAL oDlg
LOCAL cNiv := 0
DEFINE DIALOG oDlg NAME "DLGBOX" OF oWnd
REDEFINE GET cGET1 ID 101 OF oDlg PICTURE "XXXXXXXXXX"
REDEFINE GET cGET2 ID 102 OF oDlg PICTURE "XXXXXXXXXX"
REDEFINE BUTTON ID 901 OF oDlg ACTION (cNiv:=9,oDlg:End()) // = OK-button
REDEFINE BUTTON ID 902 OF oDlg ACTION (cNiv:=0,oDlg:End()) // = Cancel-button
ACTIVATE DIALOG oDlg CENTERED
IF LastKey() = VK_ESCAPE ; cNiv := 0 ; ENDIF
IF cNiv = 9 .OR. (cNiv = 0 .AND. MsgYesNo("The data have been changed. Do you want the data to be save anyway ?")
// Here the data are saved.
ENDIFRegards,
Michel D.
Genk (Belgium)
I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773
if GetKeyState(VK_ESCAPE)
<Esc was pressed, do something>
else
<Esc wasn't pressed, do something else>).
endifRegards,
Michel D.
Genk (Belgium)
I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773
My situation is:
I have an object "get" that opens up on a xbrowse, into a dialog that was open on top of another (as modal)
Where, when focused on "get", I press the ESC key he should only one run "oGet:end()", but closes the dialog where is the xbrowse too!
I would just finish the object "get", without closing the dialog! It is possible?
Julio,
As someone else mentioned, use the VALID clause of the dialog.
activate dialog oDlg valid (oGet:end(), .f.)
But it is not quite so simple because you also need to be able to close the dialog and when you always return .f. from the valid clause then you can't close the dialog.
So you will need to do something like:
activate dialog oDlg valid (valtype(oGet)!=nil, (oGet:end(), .f.), .t.)
Regards,
James
James,
I see it! But this is not work!
I saw the solution mentioned but it does not serve.
When I am typing anything into "get", I can access anything in the dialog because it is empowered normally.
So if I press the escape key, only closes the get and not the dialog together
Julio,
>So if I press the escape key, only closes the get and not the dialog together
I am not sure what you are saying again. I thought that you wanted to close the GET without closing the dialog? Are you now saying that you want to close them both at the same time?
Did you try my example VALID?
James