Thread Tools Display Modes
10-31-10, 01:33 AM   #1
Chamenas
Premium Member
 
Chamenas's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 14
Edit box Focus Issues

Hey guys.

The issue I'm having is that when I make this edit box it specifically has focus issues that make it impossible for me to jump, or use the enter key to open up the edit box for the default chat frame. Furthermore, even though the edit box seems to have focus issues, I can't actually type stuff into it.

Here are the relevant bits of code:
Code:
function PowerBars:CreateEdit(parent, name, text, width, height, multi, numeric, password, maxletters, insets)
	local width = width or 50;
	local height = height or 20;
	if width == "def" then
		width = 50;
	end
	if height == "def" then
		height = 20;
	end
	local multi = multi or 0;
	local numeric = numeric or 0;
	local password = password or 0;
	local maxletters = maxletters or 0;
	local text = text or nil;
	local insets = insets or {0,0,0,0};
	newEditBox = CreateFrame("EDITBOX", name, parent, "INPUTBOXTEMPLATE");
	newEditBox:SetText(text);
	newEditBox:SetSize(width, height);
	if multi == true or multi == "isMulti" then
		newEditBox:SetMultiLine(true);
	end
	if numeric == true or numeric == "isNum" then
		newEditBox:SetNumeric(true);
	end
	if password == true or password == "isPass" then
		newEditBox:SetPassword(true);
	end
	if maxletters > 0 then
		newEditBox:SetMaxLetters(maxletters);
	end
	newEditBox:SetTextInsets(insets[1],insets[2],insets[3],insets[4]);
	return newEditBox;
end

PowerBars.Edits.BaseOpacity = PowerBars:CreateEdit(PowerBars.panel, "PBEdits_BaseOpacity", PowerBarsDB.PowSet.BaseFrameAlpha*100, "def", "def", "notMulti", "isNum");
	BaseOpacity.Edit = PowerBars.Edits.BaseOpacity;
	BaseOpacity.Edit:SetPoint("TOP", BaseOpacity.Slider, "CENTER");
	BaseOpacity.Edit:ClearFocus();

BaseOpacity.Edit:SetScript("OnEscapePressed", 
		function(self)
			self:ClearFocus(); 
		end);
	BaseOpacity.Edit:SetScript("OnUpdate",
		function(self)
			_G[BaseOpacity.Slider:GetName() .. 'Text']:SetText("'0 power' Opacity: "..(math.floor(self:GetText()*100)));
			self:SetText((math.floor(self:GetText()*100)));
			PowerBarsDB.PowSet.BaseFrameAlpha = self:GetText();
			Res.Texture:SetAlpha(PowerBarsDB.PowSet.BaseFrameAlpha);
		end);
BaseOpacity is a local table created earlier.

Any help would be appreciated.

Edit: Putting newEditBox:SetAutoFocus(false) in the creation function fixes the focus issue but doesn't allow me to type in the box. Also, it's sort of dumb that AutoFocus is set true by default...

Last edited by Chamenas : 10-31-10 at 01:36 AM.
  Reply With Quote
10-31-10, 01:51 AM   #2
Chamenas
Premium Member
 
Chamenas's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2010
Posts: 14
And now it mysteriously wants to work...

if a Mod could delete this please?
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Edit box Focus Issues


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