Set text cursor position in edit box

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
harkathmaker
Posts: 39
Joined: Wed Jun 10, 2009 11:28 pm
Location: Portland, Oregon
Contact:

Set text cursor position in edit box

Post by harkathmaker »

Is there a way to change where the "typer" is (where you type) in an IGUIEditBox?

Basically, I want to have some default value displayed, but I want the "typer" to start typing after rather than before the starting text.

Ugh... here is a pseudo-example:

default_val = "foo"

User opens the text field and types "rawr."

Before starting text: "rawrfoo"

After starting text (what I want): "foorawr"

I was hoping for some function like "SetTyperPosition()", but I can't find anything of the sort. :(
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

There is a value "CursorPos" in CGUIEditBox but it's not exposed. You'll have to add setter methods to IGUIEditBox and CGUIEditBox in order to change it.

Basically just:

In CGUIEditBox.h:

Code: Select all

virtual void setCursorPosition(s32 pos) {if(pos < Text.size()) CursorPos = pos;}
and

In IGUIEditBox.h:

Code: Select all

virtual void setCursorPosition(s32 pos) = 0;
You may want to add this as a feature request to the tracker as it would be pretty easy to add to the engine.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Post Reply