Diese Seite mit anderen teilen ...

Informationen zum Thema:
WinDev Forum
Beiträge im Thema:
Erster Beitrag:
vor 5 Jahren, 9 Monaten
Letzter Beitrag:
vor 5 Jahren, 9 Monaten
Beteiligte Autoren:
DarrenF, Bart VDE, Al, Paulo Oliveira, GuenterP

[WD17] How to detect a push button press...

Startbeitrag von DarrenF am 10.10.2012 07:40

Hi Guys,

If I have focus on an entry field on a window and the user presses a push button elsewhere on the window which then causes the Exit event of the entry field to fire, how do I detect the button press and which button it was?

I've tried
IF MyButton..Pushed = True THEN...



Hi Darren,

each button has processes (right click on that button, choose Code F2 from popup menu) and there ('Click_ButtonXYZ') you can write what should happen if the button is clicked. If you want to know the last control 'in edit' before clicking happened - ControlPrevious() is your friend.


von GuenterP - am 10.10.2012 08:07
Hi Guenter,

I think the key here is that I need to know which push button was pressed while in the Exit event of the entry field.

To put it another way, while processing the Exit event, I need to test that it was the pressing of this button that caused the loss of focus on the entry field.

von DarrenF - am 10.10.2012 08:55
Maybe controlover in the exit code of the edit control can help you.


von Paulo Oliveira - am 10.10.2012 11:16
Hello Darren

I have a very structured environment in my apps ( or so I like to think ) and I use the same names for buttons in all windows so the close button is always "BT_Close", the save button is always "BT_SAVEREC" and so on.

With that structure I can test for a specifically named button being pressed in the exit of any field by using nextfield(), so the first line in the exit code of most of my edit fields is a call to a global proc ExitBtChk() In my case I use it to exit the control without running any error checking on that control, but you could do whatever you need to do. If you have lots of different button names it could get a bit cumbersome using a global proc.

//Check the next field when exiting a control
//if it is one of the named buttons then
//execute that code

IF NextField() = "BT_SaveRec"
IF NextField() = "BT_CLOSE" //reports


von Al - am 10.10.2012 11:19

You can also make your button of the type "Interrupt". (in the GUI of the description window)
In that case the code of the button is executed (where you can for example assign the name of the button to a global variable) without taking the focus (and so the exit event of your input field isn't executed when clicking the button)


von Bart VDE - am 12.10.2012 12:59
Hi guys,

Thanks to everyone who got involved - it's always good to talk... :spos:

The window I was discussing is an ePos screen and I was trying to "help" the user with regard to selecting a standard "Sale" or a "Refund".

What I've ended up doing is separating the processing, so that the default transaction type is a "Sale" and the user must select refund before scanning the product barcode. After the refund transaction has taken place, the window then defaults back into "Sale" mode.

...I think it works quite well... [[5]]

von DarrenF - am 12.10.2012 13:09
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.