Page 1 of 1

Events for all gadgets ?

Posted: Tue Mar 30, 2004 1:41 am
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!

Posted: Tue Mar 30, 2004 3:02 am
by Hiller
Wath you problem?

more precisely :?

Events for all gadgets

Posted: Tue Mar 30, 2004 11:17 pm
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!

Posted: Wed Mar 31, 2004 1:10 am
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:

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

Posted: Wed Mar 31, 2004 2:05 am
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?

Posted: Wed Mar 31, 2004 5:49 am
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:

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

Posted: Wed Mar 31, 2004 6:17 am
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. ;)

Posted: Wed Mar 31, 2004 6:36 am
by Hiller
He's rights.
All in documentation :lol:

Thanks

Posted: Wed Mar 31, 2004 4:15 pm
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.