Feature Reaquest - Increased Static Text functionality

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
Mloren
Posts: 114
Joined: Mon Aug 07, 2006 2:30 am
Location: Australia
Contact:

Feature Reaquest - Increased Static Text functionality

Post by Mloren »

There are two things you can't do with static text that are really bothering me:

1. You cannot click and drag over static text to highlight it so you can copy and paste it elsewhere.

2. you cannot set different colors within one piece of static text.

I am trying to use it for a chat window, and being able to copy text out of it would be handy and not being able to set different colors is very annoying.
I would like to have the speakers name in a different color to the text they say.

Doesn't look like there's a way to do this currently though.
Any chance of either of these being added?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

I'm not the GUI maintainer, but IMHO not. Different colors would bloat the API and text color syntax too much. And selectable text is often not desired in places where static text is used.
Just search for the chat console implementations that have been made in the past. Should work for your cases pretty well.
Sylence
Posts: 725
Joined: Sat Mar 03, 2007 9:01 pm
Location: Germany
Contact:

Post by Sylence »

I agree on the copy and paste. That's what edit boxes are made for.

But for the second point:
Maybe we could have some kind of parser that would allow use to add this functionality if we want. The built in one could just don't touch the text at all but if we want to we can exchange the parser with an own implementation where we could define our own syntax for coloring texts, switching fonts, and so on?
Software documentation is like sex. If it's good you want more. If it's bad it's better than nothing.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Well, there have been such gui elements already, as mentioned. I'm not sure why they were not integrated into the engine, but I suppose that it was too specific and performance hungry. If there's a suggestion for a better integration it could be worth submitting a patch :)
greenya
Posts: 1012
Joined: Sun Jan 21, 2007 1:46 pm
Location: Ukraine
Contact:

Post by greenya »

Mloren,

as a variant you can try to draw 2 separate IGUIStaticText objects: each with own color.
Next method allows to get width (in pixels) how much space the text (user name in your case) needs to be drawn, so you can draw second static text (user message in your case) right next to the previous text just by add an offset by X coord.
s32 irr::gui::IGUIStaticText::getTextWidth();

Returns the width of the current text, in the current font.
If the text is broken, this returns the width of the widest line.
(c) http://irrlicht.sourceforge.net/docu/cl ... 1d4cba7e5d
Mloren
Posts: 114
Joined: Mon Aug 07, 2006 2:30 am
Location: Australia
Contact:

Post by Mloren »

hybrid wrote:And selectable text is often not desired in places where static text is used.
I can't imagine why you would ever want static text to not be selectable.
It always bugs me when a program brings up an error or other message box and you cant select the text to copy and paste it (eg to paste it into google to find out what the error means).
Sylence wrote:I agree on the copy and paste. That's what edit boxes are made for.
The problem is they can also always be edited. What if I want text that can be selected/copied but not altered by user.

It seems like either the static text should have an option to set it as selectable or the edit box should have an option to disable user altering.
Bate
Posts: 364
Joined: Sun Nov 01, 2009 11:39 pm
Location: Germany

Post by Bate »

Agreed.

IMHO Mloren is absolutely right -- I like to copy-paste everything as well. :)
Never take advice from someone who likes to give advice, so take my advice and don't take it.
puh
Posts: 356
Joined: Tue Aug 26, 2003 3:53 pm

Post by puh »

Why you can't just use setEnabled function for IGUIEditBox for disable user altering?
CuteAlien
Admin
Posts: 9682
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Ok, as for colors: I guess that should rather be an own element.

But copying text would certainly be useful. I already have a bunch of other open patches for IGUIStaticText (mostly for scrolling), so when get to adding those I'll look into it.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply