Jump to content
das attorney

Tooltip multiple lines

Recommended Posts

Hi all,

I'm trying to make a tooltip with text over multiple lines.

I can make a tooltip no problem with just one line of text

_button ctrlSetTooltip "some text";

But if I try something like:

_button ctrlSetTooltip "some text\nSome more text";

Then it displays exactly like it's written. So the \n newline character does nothing.

I can't use something like

_txt = composeText ["some text", lineBreak, "Some more text"];
_button ctrlSetTooltip _txt;

because Arma expects a string and this is datatype text. It's definitely possible because when you mouse over items in the player inventory, you get tooltips with 3 lines of text.

Does anyone know how this is done?

Share this post


Link to post
Share on other sites

I never could get multi-line support out of tooltips.. Correct me if I'm wrong but I think BIS handles their inventory multi-line tooltips differently.

Share this post


Link to post
Share on other sites

I've tried this:

_txt = composeText ["some text", lineBreak, "Some more text"];
_tooltip = format ["%1",_txt];
_button ctrlSetTooltip _tooltip;

And the tooltip displays "some textSome more text";

Think you could be right there about the inventory; I'm fresh out of ideas trying to get this to work.

Share this post


Link to post
Share on other sites

Do tooltips support structuredText, i.e. parseText "Hey<br/>macarena!";?

Share this post


Link to post
Share on other sites

I tried that before but it throws an error because it's being fed text rather than a string:

Error in expression < parseText "Hey<br/>macarena!";
Error ctrlsettooltip: Type Text, expected String

Share this post


Link to post
Share on other sites

Hmm, how about somtheing like:

_hey = "Macarena";
_temptext = format ["Heeeeey %1!",_hey];
_diagtext = str _temptext;
_button ctrlSetTooltip _diagtext;

Share this post


Link to post
Share on other sites

Or you could make an initially hidden RscStructuredText, which will become visible onMouseEnter and update the position onMouseMoving. I know it is complicated as hell, but you'll be done sooner than you would be if you searched for a solution from BIS files. :)

I haven't managed to make nicer tooltips either. I've spent hours searching on how BIS does what they do eg. in the gearMenu, but I guess it is all engine handled stuff: I couldn't find anything in the pbos that has anything to do with the nicer/more special stuff in their UIs.

Share this post


Link to post
Share on other sites

you can use onMouseEnter and onMouseExit to display the RscStructuredText tooltip, or a rscTitle (but the tool tip will not be surrounded by a box).

I would probably recommend using rscTitle, as rscTitle's cannot take focus away from a control (where the RscStructuredText can)

Share this post


Link to post
Share on other sites

I was looking into this as well for use with descriptionShort but ultimately couldn't find an answer. There was a feedback ticket about it but I can't seem to find it again.

I think I am going to use one of the CBA functions to replace the "<br />" with a space.

EDIT:

I was looking into lbSetToolTip at the time but it has the same line break problem.

Here is the ticket:

http://feedback.arma3.com/view.php?id=9994

Edited by Fight9

Share this post


Link to post
Share on other sites

Thanks for the replies guys - I might go ahead with the onMouseEnter&onMouseMoving method when I've got more time but I'd rather suck it up and get on with others things right now.

Voted that ticket up - hopefully it gets re-reviewed at some point!

Share this post


Link to post
Share on other sites

I might do that mate - was thinking of some better ways of doing things, but it's on the backburner at the moment because TakeMagazine is broken with no fix on the horizon afaik and I've also got something (hopefully) really cool and totally different on the way.

Will keep it in mind though mate :)

Share this post


Link to post
Share on other sites

Off topic but why can't you simply delete the given magazine from the box and add it to the unit? That's the path I am going, I find most actions to be unreliable...

Share this post


Link to post
Share on other sites

I need to add partially deleted mags from one vehicle to another - If we del the mags and addMag to another one then the players get topped up magazines 'for free'.

I suppose I could use a dummy unit and add the mag to them then set the ammo with this:

https://community.bistudio.com/wiki/addMagazine_array

And then pass it on to the destination vehicle.

It's a total hassle though, be nice if there was a way of transferring a magazine by it's inventory ID without using actions.

Share this post


Link to post
Share on other sites

Just as an addendum, it seems BIS do use some other magic as I noticed this when looking in the config viewer:

descriptionshort = "Caliber: 6.5x39 mm<br />Rounds: 100<br />Used in: MX SW";

So it would seem that the <br /> syntax works to break a line in their inventory tooltips, but not on user-created ones.

Share this post


Link to post
Share on other sites

I am pretty sure they do it in the engine directly and not by sqf.

The reason I am saying this is that you can only find the UI framework in the pbos. (the RscInventory Dialog whatever its called) You can only open an empty gear window using the sqfs and hpps without the gear action. (I tried that there are handleGear.sqf and such, but you cannot get the gearmenu populated)

I think this makes certain features unreachable for human users (let's hope only for now). It seems using structured text in tooltips is one of them. The other is keeping track of ammo. :)

Share this post


Link to post
Share on other sites

This works for me...

_Control lbSetTooltip [_ID, format['%1<br/>%2<br/>%3<br/>%4','My Multi-line Tool-tip:','Line 1','Line 2','Line 3']];

Share this post


Link to post
Share on other sites

This works for me...

_Control lbSetTooltip [_ID, format['%1<br/>%2<br/>%3<br/>%4','My Multi-line Tool-tip:','Line 1','Line 2','Line 3']];

This doesn't work. How do you get it to work?

Share this post


Link to post
Share on other sites

Hey guys, if it's not too late and somone else stumbles upon this problem then I might have found a solution:

_tooltip = str composeText ["Line1",toString [13, 10],"Line2"];
_control ctrlSetTooltip _tooltip;

The "toString [13, 10]" is the linebreak.

  • Like 1

Share this post


Link to post
Share on other sites
On 06.04.2017 at 5:56 PM, 7erra said:

Hey guys, if it's not too late and somone else stumbles upon this problem then I might have found a solution:


_tooltip = str composeText ["Line1",toString [13, 10],"Line2"];
_control ctrlSetTooltip _tooltip;

The "toString [13, 10]" is the linebreak.

Thanks.

_displayName = getText(configfile >> "CfgMagazines" >> ((primaryWeaponMagazine player) select 0) >> 'DisplayName');
_descriptionShort = getText(configfile >> "CfgMagazines" >> ((primaryWeaponMagazine player) select 0) >> 'descriptionShort');
_mut= [_descriptionShort, "<br />"] call CBA_fnc_split;
_tooltip = str composeText [_displayName,toString [13, 10],_mut select 0,toString [13, 10],_mut select 1,toString [13, 10],_mut select 2];
_display displayctrl _idc_mainmag_slot ctrlSetTooltip _tooltip;
_display displayctrl _idc_mainmag_slot ctrlSetTooltipColorShade [0,0,0,1];

 

Share this post


Link to post
Share on other sites
On 4/6/2017 at 2:56 PM, 7erra said:

Hey guys, if it's not too late and somone else stumbles upon this problem then I might have found a solution:


_tooltip = str composeText ["Line1",toString [13, 10],"Line2"];
_control ctrlSetTooltip _tooltip;

The "toString [13, 10]" is the linebreak.


You can use endl instead https://community.bistudio.com/wiki/endl

  • Like 2

Share this post


Link to post
Share on other sites

This also works as of 1.68

_control ctrlSetToolTip format["Wallet: $%1 \nBank Balance: $%2", _this select 0, _this select 1];

 

  • Like 2

Share this post


Link to post
Share on other sites

Also you can use this (if you don't know about <br/> count):

_tooltip = getText(_itemCfg >> "descriptionShort");
_tooltip = ([_tooltip, "<br />", true] call BIS_fnc_splitString) joinString "\n";

BIS_fnc_splitString
joinString

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×