PDA

View Full Version : Setting a tooltip, works one way, not another...



celestian
November 12th, 2019, 17:50
For this requirement I need to be able to add a CR\r (return) in the text so it looks something like this.



NPC: do something there.
PC: do something here.


So I thought I could just set the string value to this.



<string name="cta_hptotal_tooltip"">NPC: Double click to adjust base HP.\rPC: Open Combat details section to adjust.</string>


And then just assign it as normal. <tooltip textres="cta_hptotal_tooltip" />.

But all that did was set the tooltip to the literal value and showed the "\r" instead of added the return/CR. I knew I'd done this (programmatically for another situation) before so I dug around and found it and manually set it this way.



function onInit()
local aHPTotalTip = {};
table.insert(aHPTotalTip, Interface.getString("cta_hptotal_npc_tooltip"));
table.insert(aHPTotalTip, Interface.getString("cta_hptotal_pc_tooltip"));
setTooltipText(table.concat(aHPTotalTip, "\r"));
end


I split the string into _npc and _pc values then used table concat and it works.

https://i.imgur.com/Ouu2y3o.png

This seems like odd behavior. Is there some translation going on for \r in the concat im missing?

Trenloe
November 12th, 2019, 17:53
This seems like odd behavior. Is there some translation going on for \r in the concat im missing?
Probably in the setTooltipText API call.

celestian
November 12th, 2019, 18:36
Probably in the setTooltipText API call.

That was mostly what I was getting at tho my wording wasn't so clear. I'm wondering if the way <tooltip textres="cta_hptotal_tooltip" /> pulls in the variable if it automatically escapes characters.... tho im pretty sure I use \t somewhere and it doesn't for that.

Moon Wizard
November 14th, 2019, 18:39
String assets will encode "\\r" as carriage returns ("\r") on load in v3.3.9.

Regards,
JPG

celestian
November 14th, 2019, 19:06
String assets will encode "\\r" as carriage returns ("\r") on load in v3.3.9.

Regards,
JPG

So, to be clear you mean if I set it to:



<string name="cta_hptotal_tooltip">PC: Do something heret.\\rNPC: Do another thing here..</string>


It should work in 3.3.9? I tested after updating (im on Test channel, no local CoreRPG folder) and it dropped a \ but otherwise looked the same (no return).

Moon Wizard
November 14th, 2019, 19:44
No, just leave a \r (single slash). I literally just put it up right after posting.

Regards,
JPG

celestian
November 14th, 2019, 21:05
No, just leave a \r (single slash). I literally just put it up right after posting.

Regards,
JPG

Got ya, works, thanks ;) My brain couldn't translate that properly I guess.