Page 1 of 1

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

Posted: Thu Apr 03, 2025 4:20 pm
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.

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

Posted: Thu Apr 03, 2025 4:36 pm
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

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

Posted: Thu Apr 03, 2025 4:38 pm
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:

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

Posted: Thu Apr 03, 2025 9:53 pm
by jacdelad
Yeah, the DateGadget is a bit tricky.