Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2009-10

More MaskEdit questions

12 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Bart

I found a rather disturbing behaviour of MaskEdit in Delphi (3 Pro).

Try this in Delphi:

MaskEdit1.EditMask := 'ccc-ccc-ccc;1;_'

Type in the control so the text in the control becomes "1-2-3-4-5-6" (without the quotes)
(This text is a valid text for this mask)

Observe:
MaskEdit1.Text = "1-2-3-4-5-6" (without the quotes), which is as expected

Now do:
  MaskEdit1.Text := MaskEdit1.Text; (disable optimizations!!)
  (or do MaskEdi1.Text := '1-2-3-4-5-6';)

Expected behaviour:
Nothing changes

Observed behaviour:
Text in the control now is "1__-2__-3-4" (without the quotes)

This seems to me a horrible bug in Delphi (D3 at least) MaskEdit behaviour.

Current Lazarus implementation does not behave like this.

The problem occurs when you set Text that has a MaskLiteral in the text, as soon as it finds one, it skips the remaining text in the control and continues after that MaskLiteral.
(This issue only applies when MaskNoSave is _NOT_ applied to the mask)

This makes saving Text and restoring it in a MaskEdit (or masked DBEdit) unsafe if EditMask contains MaskLiterals!

Can anyone do this experiment in a recent Delphi version to see what happens?

If this behaviour is present in recent Delphi, I fail to see how we should implement TCustomMaskEdit.SetText.
- Doing it like my Delphi is a dangerous bug
- Doing it like current maskedit.pp breaks Delphi compatibility

Bart

Reply by email

Gerard N/A
to Bart

Hi Bart,

With D7 & D2010:
I have to type "1-23-45-6" to get "1-2-3-4-5-6" with this maskedit. Both MaskEdit1.Text := MaskEdit1.Text and MaskEdi1.Text := '1-2-3-4-5-6' give the same result: '"1__-2__-3-4"

From your previous posts it seems that Delphi's TMaskEdit is pretty buggy.

Would it be too complicated to implement a boolean property switch to decide whether to act like Delphi or to act the way it should ? ;-)

Regards,

Gerard.

Reply by email

Daniel Simoes de Ameida
to Gerard N/A

Hi Bart

Thanks a lot for your effort in MaskEdit routines...

Well.. since you are changing the sources... here comes a small behavior :)

On Brazilian's Telefone Mask, we use: "!\(99\) 9999-9999;1;_"

Note that the first char on Mask is a Literal... In Delphi7, this mask when Editing, make the cursor steps the first Literal, and I presume this is correct, sice the user never can Edit this position...

On Lazarus... When editing, it stops on first Literal... and the user need to change editing position to left to start typing...

Should I write a Bug report on Mantis ?

[]s Daniel

Conhe?a o Projeto ACBr - Automa?ao Comercial Brasil DJSystem a Loja Patrocinadora do ACBr

Reply by email

Bart
to Gerard N/A: With D7 & D2010: I have to type "1-23-45-6" to get "1-2-3-4-5-6" with this maskedit. Both…

Hi Gerard,

Thanks for the swift reply.

From your previous posts it seems that Delphi's TMaskEdit is pretty buggy.

Yeah, it really seems that way.

Would it be too complicated to implement a boolean property switch to decide whether to act like Delphi or to act the way it should ? ;-)

Even "simply" implementing it the way Delphi does is almost impossible. For instance:
EditMask = "!ccc-ccc-ccc;1;_"
Do Text := "123-456-789zzz"
Resulting text in control: 123-456-zzz

EditMask = "!ccc-ccc-ccc;1;_"
You type in the control so it becomes: "1-2-3__-___" If you read the Text property, it is "1-2-3 - " (as expected) Set Text property to "1-2-3 - ".
Resulting text in control: "__1-__2-___"
Note that now an entire "3" has gone missing

Now while ! in the editmask does _NOT_ influence reading Text, it definately influences setting Text.

It seems to work something like this:

If MaskNoSave is _NOT_ in mask

if Value is the text we want to set,
Delphi:
- if you encounter a maskliteral _in Value_ do
- copy this bit, if ! is in mask then trim left, else trim rigth
- put this bit of text in
- in the control, skip to the position after the maskliteral
- repeat until no more text

Current Lazrus interpretation:
- fill in text until you hit a maskliteral _in the control_
- go search for next occurrrence of this literal in Value
- if it is there, skip to position after literal in Value
- if it is not there, stop
- repeat until (out of text) or (out of literals in Value) or (Control is filled)

If MaskNoSave is in mask

Delphi:
- fill left to right or right to left (depending on "!" in mask), skip literals in control
- continue until out of text

Lazarus (I started implementing this)
- fill left to right or right to left (depending on "!" in mask), skip literals in control
- continue until (out of text) or (control is filled)

Notice that in this case Delphi continues filling in text even if text is longer then length of internal mask! This effectively screws up the control beyond repair.

We can either follow buggy (and almost irreproducable) Delphi behaviour or prefer data-integirety and handle the situation where MaskNoSave is not defined in mask, like we currently do, sacrificing 100% Delphi compatibility.

I would appreciate opinions on that.

Bart

Reply by email

Bart
to Daniel Simoes de Ameida: Hi Bart Thanks a lot for your effort in MaskEdit routines... Well.. since you are…

Hi Daniel

Show quoted text 9 lines
On Brazilian's Telefone Mask, we use: "!\(99\) 9999-9999;1;_" Note that the first char on Mask is a Literal... In Delphi7, this mask when Editing, make the cursor steps the first Literal, and I presume this is correct, sice the user never can Edit this position... On Lazarus... When editing, it stops on first Literal... and the user need to change editing position to left to start typing...

I suppose you mean, when entering the control, the first char, "(", is selected and you have to move the cursor one postion to the right to start typing in the control,
and in fact the cursor should be positioned at the first editable char in the control?

Bart

Reply by email

Daniel Simoes de Ameida
to Bart: Hi Daniel I suppose you mean, when entering the control, the first char, "(", is selected…

Hi Bart,

Show quoted text 5 lines
I suppose you mean, when entering the control, the first char, "(", is selected and you have to move the cursor one postion to the right to start typing in the control, and in fact the cursor should be positioned at the first editable char in the control?

Yes... You are correct... Sorry my bad english :)

[]s Daniel
Conhe?a o Projeto ACBr - Automa?ao Comercial Brasil

Equipamentos para automa??o ?
DJSystem - a Loja Patrocinadora do ACBr

____________________________________________________________________________________ Veja quais s?o os assuntos do momento no Yahoo! +Buscados http://br.maisbuscados.yahoo.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20091007/71504347/attachment.html>

Reply by email

Bart
to Daniel Simoes de Ameida

Daniel,

Autoselect wil select the whole text in the control.

What happens if you:
- select the control
- do Tab
- then do Shift-Tab

This will deselect, then re-select the control.
On Linux/GTK2 it will nicely select the first editable char in a MaskEdit if you do so.

I can't test with a DBEdit, since I have no database package installed in my current Lazarus.

(Try my updated working copy on
http://home-1.tiscali.nl/~knmg0017/devel/maskedit.pp)

Bart

Reply by email

Daniel Simoes de Ameida
to Bart

Hi Bart,

The problem remains... :(

I believe many problems reported to Maskedit are using MaskEdits with TDBEdit (at the least on Brazilians Lazarus list)

On my applications, some times is necessary use TMaskEdit instead of TDBEdit, becouse of this problems... But this is not a easy approach, because we need to syncronize TMaskEdit with DB values, using DataSet's events OnDataChange and OnUpdataData...

I can write a Demo application, using TMemDataSet, but I'm not sure if you can test it... And maybe, some problems are on TDBEdits code, and not on MaskEdit....

I belive I dont have enough skills to fix this... So... if some one of Lazarus Developers could teste it, I will write a bug report on Mantis, and attach a Demo Project.

[]s Daniel

Conhe?a o Projeto ACBr - Automa?ao Comercial Brasil DJSystem a Loja Patrocinadora do ACBr

Reply by email

Bart
to Daniel Simoes de Ameida

Hi Daniel,

The problem remains... :(

Sorry to hear that.

I believe many problems reported to Maskedit are using MaskEdits with TDBEdit (at the least on Brazilians Lazarus list)

As I understand it (in Delphi) the mask in DBEdit is not handled by TMaskEdit, but by the mask of the field?

I will write a bug report on Mantis, and attach a Demo Project.

That is the way to go.
Let someone with knowledge of TDBEdit

Reply by email