lib.masked - enhancement suggestion

Currently if one autosized the masked controls they use the character "M" to calculate the size of the control, this oversizes the control quit a bit.

E.g. I have a 50 character masked control and it gets sized to 558 pixels, entering this text:

"lets have some text which is 50 characters long --"

uses 260 pixels, using "M"*50 uses the full control size.

With the attached patch applied the masked control is getting sized to 310 pixels, which is still 50 pixels larger then is needed for the above text, but if the majority of characters is of a wide type like the "M" then the control doesn't show it all, but still accepts it.

The attached uses instead of "M" the characters "FDSJKLREUI" which are the characters placed in the "center" of the keyboard.

The adjust factor for the combobox is bigger to account for the down arrow.

Any chance this would be accepted?

Werner

maskededitbettersizing.patch (783 Bytes)

Hi,

maskededitbettersizing.patch (1.44 KB)

···

On 13/02/2012 11:42, werner wrote:

Currently if one autosized the masked controls they use the character "M" to calculate the size of the control, this oversizes the control quit a bit.

E.g. I have a 50 character masked control and it gets sized to 558 pixels, entering this text:

"lets have some text which is 50 characters long --"

uses 260 pixels, using "M"*50 uses the full control size.

With the attached patch applied the masked control is getting sized to 310 pixels, which is still 50 pixels larger then is needed for the above text, but if the majority of characters is of a wide type like the "M" then the control doesn't show it all, but still accepts it.

The attached uses instead of "M" the characters "FDSJKLREUI" which are the characters placed in the "center" of the keyboard.

The adjust factor for the combobox is bigger to account for the down arrow.

Any chance this would be accepted?

My first go at this was too naive, while it worked in my application when I remembered to check the demo this morning I noticed issues with smaller masked controls, so attached is my second try at this.

Werner

Hi,

My last approach was still too naive:-[ .

Lines 2867 and 2874 should be:

                     sizing_text = 'FDSJKLREUI' * ((self._masklength/10)+1)

instead of only:
                     sizing_text = 'FDSJKLREUI' * (self._masklength/10)

Otherwise fields of e.g. 25 character length will only be sized for 20 characters, with the above change they will be sized for 30 characters.

Robin, if above is o.k. would you make the change or would you like a patch for it?

Werner

Hi,

My last approach was still too naive:-[ .

Lines 2867 and 2874 should be:

                     sizing_text = 'FDSJKLREUI' * ((self._masklength/10)+1)

instead of only:
                     sizing_text = 'FDSJKLREUI' * (self._masklength/10)

Otherwise fields of e.g. 25 character length will only be sized for 20 characters, with the above change they will be sized for 30 characters.

Robin, if above is o.k. would you make the change or would you like a patch for it?

Werner

Please do it as a patch. That drastically reduces the possibility of errors on my part. :wink:

···

On 11/5/12 7:12 AM, Werner wrote:

Hi,

My last approach was still too naive:-[ .

Lines 2867 and 2874 should be:

                     sizing_text = 'FDSJKLREUI' * ((self._masklength/10)+1)

instead of only:
                     sizing_text = 'FDSJKLREUI' * (self._masklength/10)

Otherwise fields of e.g. 25 character length will only be sized for 20
characters, with the above change they will be sized for 30 characters.

Robin, if above is o.k. would you make the change or would you like a
patch for it?

--
Robin Dunn
Software Craftsman

Would there be a nice/clean way to be able to multiply with a float or similar to get a more precise value?

Anyway here it is what I currently do which over sizes a bit.

Werner

maskededitbettersizing-add.patch (943 Bytes)

···

On 09/11/2012 02:13, Robin Dunn wrote:

On 11/5/12 7:12 AM, Werner wrote:

Hi,

My last approach was still too naive:-[ .

Lines 2867 and 2874 should be:

                     sizing_text = 'FDSJKLREUI' * ((self._masklength/10)+1)

instead of only:
                     sizing_text = 'FDSJKLREUI' * (self._masklength/10)

Otherwise fields of e.g. 25 character length will only be sized for 20
characters, with the above change they will be sized for 30 characters.

Robin, if above is o.k. would you make the change or would you like a
patch for it?

Please do it as a patch. That drastically reduces the possibility of errors on my part. :wink:

Hi Robin,

In this one I use divmod, should be a little closer to the ideal size.

Tested it with 2.9.4 in the demo and my own code.

Werner

maskedsizing.patch (1.1 KB)

Hi Robin,

This is the best I can up with for the sizing issue of controls smaller then 10 characters wide.

With this e.g. the single char in the numctrl demo size nicely.

Werner

maskedit.patch (1.31 KB)

Thanks. I'll give it a try later.

···

On 12/26/12 11:26 PM, Werner wrote:

Hi Robin,

This is the best I can up with for the sizing issue of controls smaller
then 10 characters wide.

With this e.g. the single char in the numctrl demo size nicely.

--
Robin Dunn
Software Craftsman