setLastkey(0) ? ( Solved! )

setLastkey(0) ? ( Solved! )

Postby JC » Mon Jan 12, 2009 12:33 pm

Dear Antonio, James, Uwe and friends!!

How, after pressed ESC, I can set the last key pressed to another, or simply, cancel your execution?
Last edited by JC on Wed Jan 14, 2009 11:22 am, edited 1 time in total.
Peace and lighting!

Júlio César M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
User avatar
JC
 
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil

Re: setLastkey(0) ?

Postby JC » Mon Jan 12, 2009 6:20 pm

Somebody knows?

Exists any way to do?
Peace and lighting!

Júlio César M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
User avatar
JC
 
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil

Re: setLastkey(0) ?

Postby James Bott » Tue Jan 13, 2009 2:25 am

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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: setLastkey(0) ?

Postby JC » Tue Jan 13, 2009 11:27 am

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!
Peace and lighting!

Júlio César M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
User avatar
JC
 
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil

Re: setLastkey(0) ?

Postby driessen » Tue Jan 13, 2009 1:20 pm

Julio from Brazil,

Maybe you could have a look at http://forums.fivetechsupport.com/viewtopic.php?f=3&t=14241.

This discussion was started by me about a button-problem but it seemed to be a Lastkey()-problem.

Maybe you can find the necessary information there.

Good luck.

Michel from Belgium on the other side of the world.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: setLastkey(0) ?

Postby James Bott » Tue Jan 13, 2009 2:14 pm

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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: setLastkey(0) ?

Postby JC » Tue Jan 13, 2009 2:34 pm

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!
Peace and lighting!

Júlio César M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
User avatar
JC
 
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil

Re: setLastkey(0) ?

Postby driessen » Tue Jan 13, 2009 3:55 pm

James,

LastKey() was a function, already existing in Clipper, wasn't it ?

Julio,

Here is an example of the way I use to handle the Escape-key in my dialog box :
Code: Select all  Expand view
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.

ENDIF


If the data have been changed and the Cancel-button has been clicked or the Escape-key has been pushed, the user is alarmed that the data have been changed to prevent that data are lost.

Only, there seems to be a problem with the LastKey() function in comparison with the one I was used to in Clipper. (see my topic http://forums.fivetechsupport.com/viewtopic.php?f=3&t=14241)

Good luck.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: setLastkey(0) ?

Postby hua » Tue Jan 13, 2009 3:57 pm

Julio,
Maybe you could put into the valid of the Get (or dialog box, or window),
Code: Select all  Expand view
if GetKeyState(VK_ESCAPE)
    <Esc was pressed, do something>
else
   <Esc wasn't pressed, do something else>).
endif


Can't comment on lastkey() as has never used it though.
FWH 11.08/FWH 19.12
BCC5.82/BCC7.3
xHarbour/Harbour
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

Re: setLastkey(0) ?

Postby driessen » Tue Jan 13, 2009 3:59 pm

Hua,

I have a long experience that GetKeyState() isn't always working like I want to.

That's why I use a combination of GetKeyState() and LastKey() as you can see in the other topic http://forums.fivetechsupport.com/viewtopic.php?f=3&t=14241 which also handles about this problem.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: setLastkey(0) ?

Postby JC » Tue Jan 13, 2009 4:40 pm

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?
Peace and lighting!

Júlio César M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
User avatar
JC
 
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil

Re: setLastkey(0) ?

Postby James Bott » Tue Jan 13, 2009 8:09 pm

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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: setLastkey(0) ?

Postby JC » Tue Jan 13, 2009 8:52 pm

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
Peace and lighting!

Júlio César M. Ferreira

FWH 8.10 / xHB 1.1.0 / xDevStudio 0.72 / Pelles C 5.0.1 / SQLLIB 1.9
User avatar
JC
 
Posts: 445
Joined: Thu Feb 21, 2008 11:58 am
Location: Brazil

Re: setLastkey(0) ?

Postby James Bott » Tue Jan 13, 2009 8:57 pm

Michel,

>LastKey() was a function, already existing in Clipper, wasn't it ?

Yes, you are right and I confused this with the var oGet:nLastKey, so my previous comments all were refering to oGet:nLastKey. Sorry.

The Lastkey() function is probably a (x)Harbour function. The problem may be that Windows does not send all keys to the windows event queue so there is no way to get them into the lastkey() function.

I would say this about the message you are using after the user closes the dialog (in your eample). As a user I would find this very annoying. I suggest that you think in terms of probability not possibility. Yes, there is a possibility that a user changed the data and pressed the cancel button (or escape key) and really meant to press the OK button, but what is the probability that this happened? I would guess a thousand to one. So, the user is going to have to deal with this message 999 times when they really meant to do what they did. And it MIGHT only save them once in that thousand times. But, since the user will be answering this question so many times, they are not even going to be reading it and thinking about it, they are just going to answer "No" every time, even the one time when they really meant "Yes."

So, I would never use confirmation messages. They don't work and they create lots of extra work for the user.

If you eliminate your confirmation message, then you eliminate your problem with laskKey().

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: setLastkey(0) ?

Postby James Bott » Tue Jan 13, 2009 9:00 pm

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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 73 guests