Type a date into DesktopDateTimePicker?

Any way to programatically allow the user to type a date? Day TAB month TAB Year.

Most professionals want to type, not click their date.

So, don’t use that.

Add a TextField,
Add a mask “##/##/####”; use the date separator for your country
Add a LostFocus Event and there:
Set the typed date to a DateTime,
Test of the DateTime variable is OK,
Continue as if it comes from a DDTP,
Not Valid ? Clears the TFand issue a bip

Is it clear ?

You can type: Day (keyboard right arrow) Month (keyboard right arrow) Year.

2 Likes

My used code is:

Var myToday As New DateTime(2000,01,01)

// Fill the DateTime with the date string
Try
  // Test if the date is correct
  myToday = DateTime.FromString(TF_Date.Text, French_Loc, Nil)
  
  // Assign the date to your Property (below
  
Catch
  // Error: eitheir the format is incorrect or the date is wrong

  Beep
  TF_Date.Text = ""
  Return
End Try

And that allows to type the Day TAB Month TAB Year?

I use right arrow I think, but I forget.

Other thing I forget is the Hint: JJ/MM/AAAA for French Locale.

What I don’t like about a mask is that I can’t type:

4 → 9 → 1970

→ is the right arrow on the keyboard

but I can do that with a DesktopDateTimePicker.

Better: the ‘/’ appears by magic after you typed two numbers
 ;).

Admittedly it would be helpful if you could also use Tab instead of the cursor keys (because users might expect they could tab from field to field) but yes, it is certainly possible to type in a date using the non-graphical picker.

I’ve found no way to add tabbing to the picker as it doesn’t appear to be possible to change the selected part of the date (day, month, or year) programmatically, or even to determine which part is currently selected.

Of course one could easily create a container control as a replacement for the standard control. Making that work for multiple locales would require more effort though.

Maybe create a Feature Request to see if Xojo can add an option to “allow TAB” within the DesktopDateTimePicker.

Edit: looks like the TAB feature is missing from Xojo’s control, this is how it looks with macOS own control using TAB:
2025-04-09_06-23-47

I’m sure @Javier_Menendez can add that feature to the control. Maybe Stephen can create a Feature Request (I can do it later if no one creates it).

I prefer not to write 2 numbers for day/month that are only 1. Thanks.

The Einhugur DateControl allows you to tab between fields.

1 Like

Thank you. Issue created:

https://tracker.xojo.com/xojoinc/xojo/-/issues/78892

2 Likes

I use a superclass for textbox for date where I can enter ‘;’ for current date, ‘0405’ for 04/05 of current year and 040524 for 04/04/2024

1 Like