GuiTextEditCtrl cursor fix (plus some more)
by Daan Broekhof · 10/11/2004 (5:57 pm) · 5 comments
Download Code File
While at it I also improved it a bit to get cursor scrolling a-la default edit boxes in windows, which includes:
- Maintaining the offset when editbox is not in focus
- Free cursor when textlength is greater then the editbox width
- Hopping ahead or back a length (atm 1/4 of the total editbox width) when the cursor exceeds the editbox boundaries
The current code had has some commented lines which I suspect was trying to do the same (the commented lines dated more then 2 years back and were prefixed with '//BH'), so I also removed those.
Added a mTextOffsetReset bool member which is set to true when the offset needs to be recalculated (on resize or first draw), previously mTextOffset.x was abused for this (setting it to '65535'.. :P)
It now also looks at the mProfile->mTextOffset for padding (all sides), instead of a hardcoded 3 pixel vertical padding.
(but defaulting to '3' for when mProfile->mTextOffset.x is 0, as not to break backward compatibility. A better fix would be to make mProfile->mTextOffset.x have 3 as default, but I want to keep the scope of my changes small, your judgement on weither to change this too? )
Another lil addition is making the password mask character modifiable. (instead of a hardcoded '*', defaults now to '*')
I tested this quite a bit with all text alignments, but as this is my first largish hack into the source, please review it carefully..
Download the attached file for the patch (textual or diff), only files changed are 'guiTextEditCtrl.h' and 'guiTextEditCtrl.cc'.
While at it I also improved it a bit to get cursor scrolling a-la default edit boxes in windows, which includes:
- Maintaining the offset when editbox is not in focus
- Free cursor when textlength is greater then the editbox width
- Hopping ahead or back a length (atm 1/4 of the total editbox width) when the cursor exceeds the editbox boundaries
The current code had has some commented lines which I suspect was trying to do the same (the commented lines dated more then 2 years back and were prefixed with '//BH'), so I also removed those.
Added a mTextOffsetReset bool member which is set to true when the offset needs to be recalculated (on resize or first draw), previously mTextOffset.x was abused for this (setting it to '65535'.. :P)
It now also looks at the mProfile->mTextOffset for padding (all sides), instead of a hardcoded 3 pixel vertical padding.
(but defaulting to '3' for when mProfile->mTextOffset.x is 0, as not to break backward compatibility. A better fix would be to make mProfile->mTextOffset.x have 3 as default, but I want to keep the scope of my changes small, your judgement on weither to change this too? )
Another lil addition is making the password mask character modifiable. (instead of a hardcoded '*', defaults now to '*')
I tested this quite a bit with all text alignments, but as this is my first largish hack into the source, please review it carefully..
Download the attached file for the patch (textual or diff), only files changed are 'guiTextEditCtrl.h' and 'guiTextEditCtrl.cc'.
Torque Owner Christopher Beckford
Irrational Behaviour