Page 1 of 1

Detect Change on Date and Option Gadgets

Posted: Mon Dec 05, 2011 9:54 pm
by Hysteria
Firstly, apologies if this has already been answered, I did do a search.

I'm trying to get the date and option gadgets to generate a #PB_EventType_Change message.

I've tried the trick (API call) that enables changes for the Editor gadget but it doesn't work for these.

Would be grateful for a hint! :D

Many thanks

Re: Detect Change on Date and Option Gadgets

Posted: Mon Dec 05, 2011 10:00 pm
by infratec
Hi,

for the DateGadget() I found this:

Code: Select all

If OpenWindow(0, 0, 0, 200, 250, "DateGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
 
  DateGadget(0, 10, 10, 180, 25, "Datum: %mm/%dd/%yyyy Time: %hh:%ii")
 
  Exit = #False
  Repeat
    Event = WaitWindowEvent()
    Select Event
      Case #PB_Event_Gadget
        Select EventGadget
          Case 0 : Debug "Changed"
        EndSelect
      Case #PB_Event_CloseWindow
        Exit = #True
    EndSelect
  Until Exit
 
EndIf
Bernd

Re: Detect Change on Date and Option Gadgets

Posted: Mon Dec 05, 2011 10:07 pm
by infratec
For the OptionGadget() I found

Code: Select all

If OpenWindow(0, 0, 0, 140, 110, "OptionGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  
  OptionGadget(0, 30, 20, 60, 20, "Option 1")
  OptionGadget(1, 30, 45, 60, 20, "Option 2")
  OptionGadget(2, 30, 70, 60, 20, "Option 3")
  SetGadgetState(1, 1)   ; wir setzen die zweite Option als aktiv
    
  Exit = #False
  Repeat
    Event = WaitWindowEvent()
    Select Event
      Case #PB_Event_Gadget
        
        Select EventGadget()
          Case 0 : Debug 1
          Case 1 : Debug 2
          Case 2 : Debug 3
        EndSelect
        
      Case #PB_Event_CloseWindow
        Exit = #True
    EndSelect
  Until Exit
EndIf
Bernd

Re: Detect Change on Date and Option Gadgets

Posted: Mon Dec 05, 2011 11:11 pm
by Hysteria
:oops:

Well, I only hope that you didn't find it in the English-speaking forum or I can't work the search as well as standard PB event handling :D

Thank you so much Bernd.

What's strange is that I thought my original code did just that! When it didn't work for Editor, date and option gadgets, I went looking. I found the solution to the editor gadget and assumed there was a 'special' solution to the other two.

Now I just need to work out why my original code doesn't work.

Thanks again!

Re: Detect Change on Date and Option Gadgets

Posted: Mon Dec 05, 2011 11:15 pm
by Hysteria
Ahhhh, I see what's going on. Your examples aren't qualifying the EventType as changed...

You are getting any event related to that gadget.

Which seems to work! I wonder if it will backfire on me later :mrgreen:

Re: Detect Change on Date and Option Gadgets

Posted: Mon Dec 05, 2011 11:30 pm
by ts-soft
There is no "#PB_EventType_Change" documented!
The only eventtype was "#PB_EventType_LeftClick"

Code: Select all

If OpenWindow(0, 0, 0, 140, 110, "OptionGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
 
  OptionGadget(0, 30, 20, 60, 20, "Option 1")
  OptionGadget(1, 30, 45, 60, 20, "Option 2")
  OptionGadget(2, 30, 70, 60, 20, "Option 3")
  SetGadgetState(1, 1)   ; wir setzen die zweite Option als aktiv
   
  Exit = #False
  Repeat
    Event = WaitWindowEvent()
    Select Event
      Case #PB_Event_Gadget
       
        Select EventGadget()
          Case 0
            If EventType() = #PB_EventType_LeftClick : Debug 1 : EndIf
          Case 1 : Debug 2
          Case 2 : Debug 3
        EndSelect
       
      Case #PB_Event_CloseWindow
        Exit = #True
    EndSelect
  Until Exit
EndIf 
but using of eventtype is useless in this case :wink:

Greetings - Thomas

Re: Detect Change on Date and Option Gadgets

Posted: Tue Dec 06, 2011 8:29 am
by infratec
ts-soft wrote:The only eventtype was "#PB_EventType_LeftClick"
And since there is only one event,
you don't need to check the EventType() (at the moment :mrgreen: )

Bernd

Re: Detect Change on Date and Option Gadgets

Posted: Tue Dec 06, 2011 12:34 pm
by Hysteria
Thanks guys.

Yes, I know there is no Change event documented. There isn't one documented for the Editor gadget either but it can be enabled via the WinApi, hence my assumption that something similar might be possible here.

But the lonely left click event will do nicely :D

Cheers.

Re: Detect Change on Date and Option Gadgets

Posted: Wed Dec 07, 2011 7:53 pm
by USCode
Are we talking about 4.60?
#PB_EventType_Change is documented here: http://www.purebasic.com/documentation/ ... adget.html
I use it and it works fine for me.

See this thread for some background: http://www.purebasic.fr/english/viewtop ... ox#p334254

Re: Detect Change on Date and Option Gadgets

Posted: Wed Dec 07, 2011 8:06 pm
by ts-soft
USCode wrote:Are we talking about 4.60?
We talking about 4.60, Date- and Optiongadget, not ComboboxGadget :wink: