Thread Tools Display Modes
06-12-16, 08:23 AM   #1
VincentSDSH
Non-Canadian Luzer!
 
VincentSDSH's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2006
Posts: 350
string vs "input"

I know this has been answered before but I can't seem to locate the answer and it's bothering me. If a user inputs color codes in an input field, the return from an input field is treated differently than a string with the same codes would be -- applies to fontstrings and chat output.

They have the same metatable as strings but they don't seem handled the same way. You can see an example below (though far from the only one I've done).

Lua Code:
  1. BottleOfAspirin= {
  2.     name = "type=input color code",
  3.     type = "input",
  4.     width="full",
  5.     order = 220,
  6.     get = function() return self.BottleOfAspirin end,
  7.     set = function(i, v)
  8.         self.BottleOfAsprin = v;
  9.            
  10.         debug(v)
  11.         debug(self.BottleOfAsprin)
  12.         debug("|cffff0066"..self.BottleOfAspirin.."|r")
  13.     end
  14. },



I can't remember why the escape codes aren't escape codes and it's gnawing at what's left of my tiny little mind.
__________________
AddonsExecutive Assistant User Configurable To-Do ListLegible Mail Choose the Font for Your Mail
  Reply With Quote
06-12-16, 08:44 AM   #2
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
I assume your input is coming from the chat, and it's escaping your text so the literal characters get sent because it's for chat messages, not code.

This is just a function of the chat frame to sanitize input so people don't have their messages behave unexpectedly.
  Reply With Quote
06-12-16, 09:33 AM   #3
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
I'm sure you have your reasons, but not simply use type = "color"?
  Reply With Quote
06-12-16, 09:39 AM   #4
VincentSDSH
Non-Canadian Luzer!
 
VincentSDSH's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2006
Posts: 350
And doesn't formally reassess it in a constructor. Ok, memory slowly coming back. Thanks.

Lua Code:
  1. get = function() return self.BottleOfAsprin:gsub("|", "//") end,
  2. set = function(i, v) self.BottleOfAsprin = v:gsub("//", "|") end,
In my private addons I expose the codes for readability in the entry fields (see example) so I've been inadvertently working around the behavior for years. Went to add it into one my public addons and couldn't get the question out of my head.
__________________
AddonsExecutive Assistant User Configurable To-Do ListLegible Mail Choose the Font for Your Mail
  Reply With Quote
06-12-16, 09:58 AM   #5
VincentSDSH
Non-Canadian Luzer!
 
VincentSDSH's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2006
Posts: 350
Originally Posted by myrroddin View Post
I'm sure you have your reasons, but not simply use type = "color"?
Heh, yes: user discretion interior-text color tagging (e.g. renaming "raid food" to "really expensive food")

Take Executive Assistant tasks, if I want to make a couple of related items but not fiddle with a sub-group for them.

[nix P->C] ea module call handler error (recheck)
[nix P->C] qi !Primary! Lookup table not error checking
[nix P->C] qi control availability logic bug
ilr: recheck handling similar to [nix P->C]

I, the author, don't want to fiddle with this; I, the user, bloody well want to do this. Occasionally.
__________________
AddonsExecutive Assistant User Configurable To-Do ListLegible Mail Choose the Font for Your Mail
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » string vs "input"


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off