Game Development Community

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'.

#1
10/14/2004 (8:28 am)
Thanks for that. The textboxes in torque have been a pet hate of mine right from the beginning, and why I did as little as possible in the world editor. I just never had the time to do something about it. but this is great. It seemed ok during my quick test and the jump ahead is perfect, to many times have I deleted decimal points because they weren't displayed yet. :)
#2
02/19/2005 (10:08 am)
Thank you, works great!
#3
05/09/2005 (10:51 am)
Thanks Daan! This works with TGE 1.3 and really should have been included in HEAD!

Nice work!

B--
#4
06/14/2005 (5:46 pm)
Gonna look at this for 1.4 HEAD.
#5
08/04/2005 (10:07 pm)
Issue #95 closed. Nice code.