Recent

Author Topic: Problem with DateTimePicker  (Read 5953 times)

Sieben

  • Sr. Member
  • ****
  • Posts: 310
Re: Problem with DateTimePicker
« Reply #30 on: November 23, 2020, 09:45:49 pm »
Very kind, thank you very much! Quite useful when you don't want to use AutoSize to eg match sizes of other controls and still have a decent look. How about DirectInput now...?  ;)

Btw is it possible to move this to a more appropriate place, eg 'Packages and Libraries'?
Lazarus 2.2.0, FPC 3.2.2, .deb install on Ubuntu Xenial 32 / Gtk2 / Unity7

Zoran

  • Hero Member
  • *****
  • Posts: 1829
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Problem with DateTimePicker
« Reply #31 on: November 23, 2020, 10:47:32 pm »
What is DirectInput?

Sieben

  • Sr. Member
  • ****
  • Posts: 310
Re: Problem with DateTimePicker
« Reply #32 on: November 23, 2020, 11:22:29 pm »
Do you really...? DirectInput is a property used for example with TFileEdit or TDirectoryEdit to prevent the user from directly entering text into the edit portion of the control but to force him to use the buttons and the dialogs behind them. In case of TDateTimePicker the calendar controls, the UpDowns or the wheel. Defaults to True (direct input allowed) but can be set to False. Not really 'needed' as well...
Lazarus 2.2.0, FPC 3.2.2, .deb install on Ubuntu Xenial 32 / Gtk2 / Unity7

Gald

  • Full Member
  • ***
  • Posts: 107
Re: Problem with DateTimePicker
« Reply #33 on: November 23, 2020, 11:25:06 pm »
Hi Zoran!

Is it possible to set the text a little bit away from the border? It's too close with the left side, the numbers are quite sharing the same pixels as the left border.

Example:

_________________
|23/11/2020      | v |
------------------------

_________________
| 23/11/2020     | v |
------------------------

Note that this is not related to text align direction but the spacing.
Lazarus 2.0.12 r64642 FPC 3.2.0 x86_64-win64-win32/win64/Manjaro KDE 21
AMD Ryzen 3 1300X Quad-Core Processor 3.50 GHz / 8,00 GB RAM / GTX 1500 TI / 2TB M.2 NVMe

Gald

  • Full Member
  • ***
  • Posts: 107
Re: Problem with DateTimePicker
« Reply #34 on: November 23, 2020, 11:42:03 pm »
_____________
|23/11/2020      | v |
------------------------

_________________
| 23/11/2020     | v |
------------------------

Actually, forget it.
This should be common to all controls.
Lazarus 2.0.12 r64642 FPC 3.2.0 x86_64-win64-win32/win64/Manjaro KDE 21
AMD Ryzen 3 1300X Quad-Core Processor 3.50 GHz / 8,00 GB RAM / GTX 1500 TI / 2TB M.2 NVMe

Zoran

  • Hero Member
  • *****
  • Posts: 1829
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Problem with DateTimePicker
« Reply #35 on: November 24, 2020, 12:12:45 am »
Do you really...? DirectInput is a property used for example with TFileEdit or TDirectoryEdit to prevent the user from directly entering text into the edit portion of the control but to force him to use the buttons and the dialogs behind them. In case of TDateTimePicker the calendar controls, the UpDowns or the wheel. Defaults to True (direct input allowed) but can be set to False. Not really 'needed' as well...

I see.
For that, you can use CalendarDialog (on Dialogs tab of control palette), together with a button and a read-only edit box (or just a label, or even a read-only DateTimePicker).
EDIT: better answer added later.

So, yes, not really needed.
And too many not really useful properties do not bring quality.
« Last Edit: November 28, 2020, 12:48:58 pm by Zoran »

Zoran

  • Hero Member
  • *****
  • Posts: 1829
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Problem with DateTimePicker
« Reply #36 on: November 24, 2020, 12:18:38 am »
_____________
|23/11/2020      | v |
------------------------

_________________
| 23/11/2020     | v |
------------------------

Actually, forget it.
This should be common to all controls.

Try setting BorderSpacing.InnerBorder property to value greater than zero.

Gald

  • Full Member
  • ***
  • Posts: 107
Re: Problem with DateTimePicker
« Reply #37 on: November 24, 2020, 01:10:04 am »
Try setting BorderSpacing.InnerBorder property to value greater than zero.

Thanks, it works.
Unfortunately, other controls don't follow the same rules.
There is no pattern about desing native controls?
Lazarus 2.0.12 r64642 FPC 3.2.0 x86_64-win64-win32/win64/Manjaro KDE 21
AMD Ryzen 3 1300X Quad-Core Processor 3.50 GHz / 8,00 GB RAM / GTX 1500 TI / 2TB M.2 NVMe

Zoran

  • Hero Member
  • *****
  • Posts: 1829
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Problem with DateTimePicker
« Reply #38 on: November 25, 2020, 01:11:38 pm »
Try setting BorderSpacing.InnerBorder property to value greater than zero.

Thanks, it works.
Unfortunately, other controls don't follow the same rules.
There is no pattern about desing native controls?

Native controls are implemented in widgetsets. Sometimes, some behaviour cannot be implemented in LCL, because the underlying widget does not behave that way.

Zoran

  • Hero Member
  • *****
  • Posts: 1829
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Problem with DateTimePicker
« Reply #39 on: November 28, 2020, 12:38:42 pm »
Do you really...? DirectInput is a property used for example with TFileEdit or TDirectoryEdit to prevent the user from directly entering text into the edit portion of the control but to force him to use the buttons and the dialogs behind them. In case of TDateTimePicker the calendar controls, the UpDowns or the wheel. Defaults to True (direct input allowed) but can be set to False. Not really 'needed' as well...


Actually, this behaviour can be achieved by setting something like this in OnKeyDown event:
Code: Pascal  [Select][+][-]
  1. uses
  2.   ...
  3.   LCLType, // needed for virtual key constants.
  4.   ...
  5.  
  6. procedure TForm1.DateTimePicker1KeyDown(Sender: TObject; var Key: Word;
  7.   Shift: TShiftState);
  8. begin
  9.   if Key in [
  10.     VK_0..VK_9, VK_NUMPAD0..VK_NUMPAD9
  11.     , VK_A, VK_P
  12.     // comment out the following line if you want to allow up and down arrow keys to change the date:
  13.     , VK_DOWN, VK_UP
  14.   ]
  15.   then
  16.     Key := 0;
  17. end;
  18.  

or you can use OnKeyPress instead, but only if you are not interested in suppressing up and down arrow keys (they cannot be caught by OnKeyPress), like this:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.DateTimePicker1KeyPress(Sender: TObject; var Key: char);
  2. begin
  3.   if Key in ['0'..'9', 'A', 'P'] then
  4.     Key := #0;
  5. end;
  6.  

Is that what you would get with DirectInput?
« Last Edit: November 28, 2020, 01:07:26 pm by Zoran »

Sieben

  • Sr. Member
  • ****
  • Posts: 310
Re: Problem with DateTimePicker
« Reply #40 on: November 28, 2020, 09:48:16 pm »
Yes, the latter one leaves it with the exact behaviour I had in mind. And it sure is easy enough to spare an extra property.
Thanks once more!  :)
« Last Edit: November 28, 2020, 09:51:15 pm by Sieben »
Lazarus 2.2.0, FPC 3.2.2, .deb install on Ubuntu Xenial 32 / Gtk2 / Unity7

 

TinyPortal © 2005-2018