Events for all gadgets ?

Just starting out? Need help? Post your questions and find answers here.
USCode
Addict
Addict
Posts: 924
Joined: Wed Mar 24, 2004 11:04 pm
Location: Seattle

Events for all gadgets ?

Post by USCode »

I've noticed that all the events available for each gadget aren't necessarily documented with the documentation for that gadget ...

Is there a documentation or constants file somewhere that details ALL the events available for all the PureBasic gadgets?

Thanks!
Hiller
User
User
Posts: 15
Joined: Mon Mar 29, 2004 12:32 am
Location: Ukraine
Contact:

Post by Hiller »

Wath you problem?

more precisely :?
USCode
Addict
Addict
Posts: 924
Joined: Wed Mar 24, 2004 11:04 pm
Location: Seattle

Events for all gadgets

Post by USCode »

I'd like to know what all the available #PB_... events are for each gadget. For example, in the documentation there are no events listed for the StringGadget. Does that mean the StringGadget doesn't generate any events?

Where can I find all the events supported by each gadget?

If not in the doc then maybe some constants file somewhere?

Thanks!
Hiller
User
User
Posts: 15
Joined: Mon Mar 29, 2004 12:32 am
Location: Ukraine
Contact:

Post by Hiller »

Hmm...
Gadget string don't have variables #PB_.. It's have flags and parent window events.

P.S. I'm bad speak to English. :wink:
USCode
Addict
Addict
Posts: 924
Joined: Wed Mar 24, 2004 11:04 pm
Location: Seattle

Valid Events for each gadget, some have none listed in doc ?

Post by USCode »

For example:

- So how can I tell they're typing in text in a string gadget if I want to trap every keystroke?

- With a combobox gadget, how can I tell they've made a selection and react to that event?

- With an option gadget, how can I react to a selection being made? Etc.

Maybe I'm missing something here?
Hiller
User
User
Posts: 15
Joined: Mon Mar 29, 2004 12:32 am
Location: Ukraine
Contact:

Post by Hiller »

So how can I tell they're typing in text in a string gadget if I want to trap every keystroke?
Using thise:

Code: Select all

Procedure KeyboardProc(nCode,wParam,temp)

     MessageRequester("KeyPress","VirtCode "+Str(wParam),0)
          
  ProcedureReturn 0
EndProcedure

OpenWindow(0,0,0,400,300,#PB_Window_Systemmenu| #PB_Window_MinimizeGadget| #PB_Window_MaximizeGadget | #PB_Window_ScreenCentered |#PB_Window_sizegadget ,"World View")
  If CreateGadgetList(WindowID(0))
     StringGadget(0,40,40,100,30,"")
  EndIf

;declare event's on user down key or user up key.
 SetWindowsHook_(#WH_KEYBOARD,@KeyboardProc())

 Repeat
     Event=WindowEvent()
 Until Event=#PB_Event_CloseWindow
or use on Event=#PB_Event_Gadget with ID StringGadget function GetGadgetText()

Etc. :wink:
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: Valid Events for each gadget, some have none listed in d

Post by PB »

> how can I tell they're typing in text in a string gadget?
> With a combobox gadget, how can I tell they've made a selection?
> With an option gadget, how can I react to a selection being made?

Best way to show all the above is with a practical example:

Code: Select all

If OpenWindow(1,0,0,400,100,#PB_Window_ScreenCentered,"test")
  If CreateGadgetList(WindowID())
    StringGadget(1,10,10,50,20,"")
    ComboBoxGadget(2,100,10,50,100)
    For r=1 To 5 : AddGadgetItem(2,-1,Str(r)) : Next
    SetGadgetText(2,"1")
    OptionGadget(3,200,10,50,20,"one") : SetGadgetState(3,#TRUE)
    OptionGadget(4,250,10,50,20,"two")
    OptionGadget(5,300,10,50,20,"three")
    Repeat
      ev=WaitWindowEvent()
      If ev=#PB_Event_Gadget ; A gadget has been clicked!
        Select EventGadgetID() ; Which one?
          Case 1 ; StringGadget clicked or typed.
            new$=GetGadgetText(1) ; Get its contents.
            If new$<>old$ ; Its contents have changed!
              old$=new$ ; Remember the new contents.
              Debug "StringGadget has been typed"
            EndIf
          Case 2 : Debug GetGadgetText(2) ; ComboBoxGadget clicked.
          Case 3 : Debug "Option1 Clicked"
          Case 4 : Debug "Option2 Clicked"
          Case 5 : Debug "Option3 Clicked"
        EndSelect
      EndIf
    Until ev=#PB_Event_CloseWindow
  EndIf
EndIf
> Maybe I'm missing something here?

Well, it's all in the manual... but as you said, not always where might be
the most logical places. Still, if you browse all sections of the manual,
you'll usually find what you want. ;)
Last edited by PB on Wed Mar 31, 2004 7:00 am, edited 1 time in total.
Hiller
User
User
Posts: 15
Joined: Mon Mar 29, 2004 12:32 am
Location: Ukraine
Contact:

Post by Hiller »

He's rights.
All in documentation :lol:
USCode
Addict
Addict
Posts: 924
Joined: Wed Mar 24, 2004 11:04 pm
Location: Seattle

Thanks

Post by USCode »

Thanks guys!
Thanks for taking the time to make the excellent example for me PB! I appreciate it, especially since it is pure PB code and no WindowAPI references. :D I am only interested in developing cross-platform apps.
Post Reply