[Done] DateGadget: Can't edit after set value with SetGadgetText

Just starting out? Need help? Post your questions and find answers here.
Marc56us
Addict
Addict
Posts: 1600
Joined: Sat Feb 08, 2014 3:26 pm

[Done] DateGadget: Can't edit after set value with SetGadgetText

Post by Marc56us »

Hi,
If I define a date in a DateGadget, I can't edit it afterwards, neither with the keyboard nor with spins. why ?

Code: Select all

OpenWindow(0, 0, 0, 300, 300, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
SetGadgetFont(#PB_Default, FontID( LoadFont(#PB_Any, "Verdana", 10) ) )

DateGadget(0, 10, 10, 195, 25, 
           "%yyyy/%mm/%dd %hh:%ii", 
           Date(), 
           #PB_Date_UpDown | #PB_Date_CheckBox)

DateGadget(2, 10, 100, 195, 25, 
           "%yyyy/%mm/%dd %hh:%ii", 
           Date(), 
           #PB_Date_UpDown | #PB_Date_CheckBox)

; Setting a date to DateGadget #2 and can't edit it after. Why ?
; Mask match and seconds not used
SetGadgetText(2, "2025/01/01 10:00")
; Check box set whatever
; SetGadgetState(2, 1)

Repeat : Until WaitWindowEvent(0) = #PB_Event_CloseWindow 
Tested PB 6.21 B3 and 5.46 (Windows x64 for both)

Edit: If I reread the doc, SetGadgetText only does the mask: you then have to set the date using SetGadgetState.
Last edited by Marc56us on Thu Apr 03, 2025 4:47 pm, edited 1 time in total.
User avatar
jacdelad
Addict
Addict
Posts: 2029
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: DateGadget: Can't edit after set value with SetGadgetText

Post by jacdelad »

SetGadgetText is used to set the input mask. To set the date, use SetGadgetState and a long value.
https://www.purebasic.com/documentation ... adget.html
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
Marc56us
Addict
Addict
Posts: 1600
Joined: Sat Feb 08, 2014 3:26 pm

Re: DateGadget: Can't edit after set value with SetGadgetText

Post by Marc56us »

jacdelad wrote: Thu Apr 03, 2025 4:36 pm SetGadgetText is used to set the input mask. To set the date, use SetGadgetState and a long value.
https://www.purebasic.com/documentation ... adget.html
Just at the same time. :mrgreen:
Thanks

The solution:

Code: Select all

SetGadgetState(2, ParseDate("%yyyy/%mm/%dd %hh:%ii", "2025/01/01 10:00"))
It was so simple that I spent several hours on it. :? :lol:
User avatar
jacdelad
Addict
Addict
Posts: 2029
Joined: Wed Feb 03, 2021 12:46 pm
Location: Riesa

Re: [Done] DateGadget: Can't edit after set value with SetGadgetText

Post by jacdelad »

Yeah, the DateGadget is a bit tricky.
Good morning, that's a nice tnetennba!

PureBasic 6.21/Windows 11 x64/Ryzen 7900X/32GB RAM/3TB SSD
Synology DS1821+/DX517, 130.9TB+50.8TB+2TB SSD
Post Reply