Detect Change on Date and Option Gadgets

Just starting out? Need help? Post your questions and find answers here.
Hysteria
User
User
Posts: 50
Joined: Sat Oct 23, 2010 8:51 am
Location: UK

Detect Change on Date and Option Gadgets

Post 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
infratec
Always Here
Always Here
Posts: 7623
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Detect Change on Date and Option Gadgets

Post 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
Last edited by infratec on Mon Dec 05, 2011 10:10 pm, edited 2 times in total.
infratec
Always Here
Always Here
Posts: 7623
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Detect Change on Date and Option Gadgets

Post 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
Hysteria
User
User
Posts: 50
Joined: Sat Oct 23, 2010 8:51 am
Location: UK

Re: Detect Change on Date and Option Gadgets

Post 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!
Hysteria
User
User
Posts: 50
Joined: Sat Oct 23, 2010 8:51 am
Location: UK

Re: Detect Change on Date and Option Gadgets

Post 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:
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Detect Change on Date and Option Gadgets

Post 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
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
infratec
Always Here
Always Here
Posts: 7623
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Detect Change on Date and Option Gadgets

Post 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
Hysteria
User
User
Posts: 50
Joined: Sat Oct 23, 2010 8:51 am
Location: UK

Re: Detect Change on Date and Option Gadgets

Post 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.
USCode
Addict
Addict
Posts: 924
Joined: Wed Mar 24, 2004 11:04 pm
Location: Seattle

Re: Detect Change on Date and Option Gadgets

Post 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
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Re: Detect Change on Date and Option Gadgets

Post by ts-soft »

USCode wrote:Are we talking about 4.60?
We talking about 4.60, Date- and Optiongadget, not ComboboxGadget :wink:
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
Post Reply