Recent

Author Topic: TMaskEdit mask question  (Read 3488 times)

brody

  • Newbie
  • Posts: 4
TMaskEdit mask question
« on: December 16, 2017, 06:39:32 pm »
Hi:
I have a edit mask with this pattern.  #999.99;0;_    (and several other variations. )

But, when I enter data, such as -53.15   the cursor JUMPS to the 10's column when I press the '.', leaving me with a field of -53_.15    which is NOT what I'm looking for.   I'm wanting -53.15.

What am I missing in the concept of the editmask?  Or do I still have to validate the output of the mask edit?

Thanks,
Brody

Bart

  • Hero Member
  • *****
  • Posts: 5290
    • Bart en Mariska's Webstek
Re: TMaskEdit mask question
« Reply #1 on: December 16, 2017, 10:33:26 pm »
IIRC then pressing '.' will just do that: jump to the first position after the dot.
AFAIK that is Delphi compatible.

Bart

jamie

  • Hero Member
  • *****
  • Posts: 6130
Re: TMaskEdit mask question
« Reply #2 on: December 16, 2017, 11:17:22 pm »
you can correct that in the OnChange event and OnKeypress etc..

 But its not really worth it I would say?

 Try the TFloatSpinEdit control instead. That have much better formatting .
Its in the Misc tab.
The only true wisdom is knowing you know nothing

jamie

  • Hero Member
  • *****
  • Posts: 6130
Re: TMaskEdit mask question
« Reply #3 on: December 17, 2017, 02:59:09 am »
Interesting, while exploring using the OnChange event of the TMaskEdit to
fix the gapping issue I find that "CaretPos" always reports 0,0 only in the
OnChange event but works in other events.

 Then I checked TEdit since they are based from the same control and the
OnChange event there does report the CaretPos.

 TMaskEdit.OnChange(....);
  Begin
     MaskEdit.CaretPos.X  always reports 0 while editing !


But this works in TEDIT.OnChange..

 lazarus 1.8 64 bit, most likely in the 32 bit too!
The only true wisdom is knowing you know nothing

Bart

  • Hero Member
  • *****
  • Posts: 5290
    • Bart en Mariska's Webstek
Re: TMaskEdit mask question
« Reply #4 on: December 17, 2017, 09:50:28 pm »
Try using selstart.

Bart

jamie

  • Hero Member
  • *****
  • Posts: 6130
Re: TMaskEdit mask question
« Reply #5 on: December 18, 2017, 12:21:54 am »
Why would I do that? The idea is to find the caretpos which reports where the
user is at the time during editing..

 Using selstart would imply I knew where things are?
Code: Pascal  [Select][+][-]
  1. [/ GetCaretPos(P);
  2.   IntPtr(P):= SendMessage(MaskEdit1.Handle,EM_CHARFROMPOS,0,MakeLParam(P.X,P.Y));      code]
  3.  
  4. That seems to work..
  5.  
The only true wisdom is knowing you know nothing

Bart

  • Hero Member
  • *****
  • Posts: 5290
    • Bart en Mariska's Webstek
Re: TMaskEdit mask question
« Reply #6 on: December 18, 2017, 08:18:39 pm »
Using selstart would imply I knew where things are?

You lost me there.

Is CaretPos accurate outside OnChange?

Bart

jamie

  • Hero Member
  • *****
  • Posts: 6130
Re: TMaskEdit mask question
« Reply #7 on: December 18, 2017, 10:51:01 pm »
Yes, in other events of MaskEdit, like Keyboards, mouse move etc, the CaretPos
reports true.

 In the Onchange revent, it always reports 0.

 By using the SendMessage approach as I outlined before, it is able to get
the actual character position using the current caret position in the control.
 
 I have reported this, I think a modification to the code is going to be done.
 
 Without this for it makes it hard to customize the MAskedit during editing
in a cross platform arena.
The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018