onscreen "keypad".

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by devices.

Hi
whilst I still have some hair left, could someone please point me in the right direction.
I am trying to give values to a series of variables using a onscreen "keypad".
The codeing I think should go something like this:-
keypad:
If WaitWindowEvent()=#PB_EventGadget And EventGadgetID()=30:a=1:c=1:EndIf
If WaitWindowEvent()=#PB_EventGadget And EventGadgetID()=30:b=1:c=0:EndIf
Return
This is just an example.
I want to give a=1 on the first click of "ButtonGadget" 30 and b=1 on the next click.
However what I get is a=1 on the first click, but nothing on the second.
What am I doing wrong?
Thanks Richard
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.

> If WaitWindowEvent()=#PB_EventGadget And EventGadgetID()=30:a=1:c=1:EndIf
> If WaitWindowEvent()=#PB_EventGadget And EventGadgetID()=30:b=1:c=0:EndIf
>
> I want to give a=1 on the first click of "ButtonGadget" 30 and b=1 on the next click.
> However what I get is a=1 on the first click, but nothing on the second.

That's because the second line (b=1) never gets seen because WaitWindowEvent is
called twice. I haven't tested it, but try an approach like this instead:

Code: Select all

If WaitWindowEvent()=#PB_EventGadget And EventGadgetID()=30
  If a=0 : a=1 : c=1 : EndIf
  If a=1 : b=1 : c=0 : EndIf
EndIf

PB - Registered PureBasic Coder
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by devices.

Thanks PB
However this gives a=1 and b=1 on a single click!
Is there any rule as to how close together "WaitWindowEvents" can be in a sub group?
All the best
Richard
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Paul.

Check in the oposite order...

If a=1 : b=1 : c=0 : EndIf
If a=0 : a=1 : c=1 : EndIf
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by devices.

Thanks for the input Paul
However this gives a=1 c=1 on the first click and nothing on the second.
May be I'm asking to much of PB.......strange as I could do this back in the 80's when I first used "Basic".
All the best Richard
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by PB.

> However this gives a=1 and b=1 on a single click!

Oops, my mistake (I didn't test it, as mentioned). Do this instead:

Code: Select all

If WaitWindowEvent()=#PB_EventGadget And EventGadgetID()=30
  If a=0
    a=1 : c=1
  ElseIf a=1
    b=1 : c=0
  EndIf
EndIf
> Is there any rule as to how close together "WaitWindowEvents" can be in a sub group?

Each time WaitWindowEvent is called, it cancels the values of the previous call.
In other words, EventGadgetID in the second call is different to the first.


PB - Registered PureBasic Coder
Post Reply