EditBox on multiple lines ?

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
c@c
Posts: 10
Joined: Sun Mar 28, 2004 8:38 pm

EditBox on multiple lines ?

Post by c@c »

Hi,
Is there any class which is like EditBox, but on multiple lines ? I haven't seen anything for that in the API reference (statictext can be multiwrapped, but it's ... static. And EditBox are single line).
Or is there a way to 'cheat' with a combo of statictext and editbox ?
(As you can see, i'm fond of editboxes :lol: )
Mr_Ridd
Posts: 63
Joined: Tue Sep 28, 2004 5:16 am

Post by Mr_Ridd »

I see what you're trying to do. Have a text box basically.

Well I don't know how to do that but for a cheat you could try this.

Draw a certain amount of edit boxes on top of each other and take there borders away. There are functions to do that.

It could work, try it. 8)
c@c
Posts: 10
Joined: Sun Mar 28, 2004 8:38 pm

Post by c@c »

Thanks for your answer : it works, even if it's a bit "basic" (not exactly the same behavior as a *real* textbox). ;-)
c@c
Posts: 10
Joined: Sun Mar 28, 2004 8:38 pm

Post by c@c »

I finally tried another way to have a textbox : i have a statictext, and when it's hovered, i display a cursor ("|") inside ... i can write, delete characters, but i have a little problem : some of my keys aren't recognized by the engine ...
For example : ?!.,;&é"'(-è_çà123456789$£, etc.
I get this message : "Could not find win32 key for x11 key.".
How can I correct that ? it's rather awkward* ... ;-)

*especially for these keys : "é" "è", because i'm french, and ".".
c@c
Posts: 10
Joined: Sun Mar 28, 2004 8:38 pm

Post by c@c »

Even if I seem to talk alone (one my favorite occupations ;-)) ... i post again.
I finally tried a third method to have a textbox : a statictext with border behind an editbox of the same dimensions and hidden (ransparent font and no border).
This is the code :

Code: Select all

class TextBox
{
	IGUIEnvironment * env;
	IGUIStaticText * TextBoxShown;
	IGUIEditBox * TextBoxImpl;
  public:
	TextBox(IGUIEnvironment*, const wchar_t*, const core::rect<s32>&, bool, IGUIElement*, s32, s32, s32);
	void update();
};
TextBox::TextBox(IGUIEnvironment* _env, const wchar_t* IniText, const core::rect<s32>& rectangle, bool border, IGUIElement* parent, s32 id, s32 id2, s32 maxLength)
{
	env = _env;
	TextBoxShown = env->addStaticText(IniText, rectangle, border, true, parent, id);
	TextBoxImpl = env->addEditBox(IniText, rectangle, true, parent, id2);
	TextBoxImpl->setOverrideColor(SColor(0,0,0,0));
	TextBoxImpl->setMax(maxLength);
}
void TextBox::update()
{
	TextBoxShown->setText(TextBoxImpl->getText());
}
So, I have juste to create the Textbox :
TextBox MytextBox(env, L"", rect<s32>(200,200,600,400), true, 0, 15, 16, 255);

And to update it at each drawing :
MytextBox.update();
Midnight
Posts: 1772
Joined: Fri Jul 02, 2004 2:37 pm
Location: Wonderland

Post by Midnight »

Interesting...

But why not just write your own "TextBox" class?

just take the editbox and/or statictext class(es) and change them to do what you need.
c@c
Posts: 10
Joined: Sun Mar 28, 2004 8:38 pm

Post by c@c »

I would be very proud to manage to do this ... but i'be some questions :
-to modify EditBox, for example : do I need to modify only "CGUIEditBox.h" and "CGUIEditBox.cpp" and they run make to compile the engine, or is there anything else to do ?
-will Irrlicht have soon an "official" textbox, or shall I modify these files each time i change my irrlicht version ?
-how can i become a cPp 3133t/m4st4 ? (just kidding)
-is my english correct ? :lol:
Masdus
Posts: 186
Joined: Tue Aug 26, 2003 1:13 pm
Location: Australia

Post by Masdus »

you wouldn't need to modify the source if you derived your new class from an existing GUI element. I can't remember the particulars but i did this when i created a GUI image button before one existed in irrlicht. I'm sure Niko gave me some pointers somewhere on this forum
Post Reply