Page 2 of 2
Re: Input numbers and add them up:
Posted: Sat Oct 15, 2022 4:07 pm
by Oso
Mindphazer wrote: Sat Oct 15, 2022 2:39 pm
If you press Enter
and the active gadget is #gad_number, or if you press the button (#gad-add) then you call AddNumber()
Thanks Mindphazer, I think the thing that confused me is that the below Select/Case, isn't specifically checking for the Enter key, but simply that #gad_number is tested as the active gadget for "whatever event" took place...
Code: Select all
ev=WaitWindowEvent()
If ev=#PB_Event_Menu
Select GetActiveGadget()
Case #gad_number,#gad_add : AddNumber()
Re: Input numbers and add them up:
Posted: Sat Oct 15, 2022 4:55 pm
by Mindphazer
Well, in fact, i don't really understand this :
Code: Select all
Case #gad_number, #gad_add : AddNumber()
In my opinion, this should be enough :
No need to check #gad_add as it's the button gadget and it's not attached to a menu
But maybe BarryG can explain this point ?
Re: Input numbers and add them up:
Posted: Sat Oct 15, 2022 5:56 pm
by Oso
Mindphazer wrote: Sat Oct 15, 2022 4:55 pm
In my opinion, this should be enough :
Yes, it seems to work fine with that amendment.
Re: Input numbers and add them up:
Posted: Sun Oct 16, 2022 12:36 am
by BarryG
This is so you can press Enter on the "Add number" button. If you remove the "#gad_add" bit, then you can't press Enter on it to add a number. I wanted my example to be fully working with keyboard as well as mouse.
Re: Input numbers and add them up:
Posted: Sun Oct 16, 2022 9:14 am
by Oso
BarryG wrote: Sun Oct 16, 2022 12:36 am
This is so you can press Enter on the "Add number" button. If you remove the "#gad_add" bit, then you can't press Enter on it to add a number.
Yes, I see. There's quite a high attention to detail on this little example. It's good to find intentional keyboard support because reaching for the mouse is slow. Thanks for posting it Barry.
Re: Input numbers and add them up:
Posted: Sun Oct 16, 2022 11:41 am
by BarryG
Thanks, Oso.
Re: Input numbers and add them up:
Posted: Sun Oct 16, 2022 7:42 pm
by AZJIO