Thread Tools Display Modes
08-04-09, 01:05 PM   #1
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
EditBox help needed

Working on a new project and have come across some new issues with editboxes. Here's the gist, I want users to be able to define their own scripts via an EditBox. Problem comes in is that I want the edit box to be multiline (which I can't seem to get to work) and the text to start in the upper left. Checked wowwiki and can't seem to find anything useful to help me do this.

Code:
e = CreateFrame("EditBox", "CART_ScriptBox", parent)
	e:SetWidth(292)
	e:SetHeight(100)
	e:SetPoint("BOTTOMLEFT", parent, "BOTTOMLEFT",4,4)
	e:SetBackdrop({
			bgFile = "",
			edgeFile = "Interface\\Tooltips\\UI-Tooltip-Border",
			tile = "true",
			tileSize = 32,
			edgeSize = 10,
			insets = {left = 3, right = 3, top = 3, bottom = 3}
		})
	e:SetFontObject("GameFontNormalSmall")
	e:SetTextInsets(5,0,0,0)
	e:IsMultiLine(true)
	e:SetAutoFocus(false)
	e:SetScript("OnEscapePressed", e.ClearFocus)
So after typing text in, it doesn't wrap around and hitting enter doesn't go to a new line.
  Reply With Quote
08-04-09, 01:07 PM   #2
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,934
You might have to set another anchor to anchor the top of the frame as per this portion of text from the EditBox page of wowwiki.

On multi-line and EditBox:SetHeight() Note that multi-line EditBoxes will ignore any attempts to set its height via :SetHeight() or via Dimension attributes in XML. They will start out the height of a single line of text, and keep expanding their area as needed. This effect becomes visible if the editbox has a backdrop set, or a texture anchored to its corners.

Explicitly setting the top and bottom anchors with :SetPoint() will however size it like expected.

Also, you may have to implement the OnEnterPressed event script to move the cursor manually to the next line. As this OnTabPressed example shows. Also from the wowwiki pages.

EditBox:SetScript("OnTabPressed", function(self)
self:Insert(" "); -- (4 spaces)
end;
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818

Last edited by Xrystal : 08-04-09 at 01:11 PM.
  Reply With Quote
08-04-09, 01:25 PM   #3
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
So basically have a fontstring set on top of it?
  Reply With Quote
08-04-09, 01:39 PM   #4
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,934
It sounds like it has a fontstring built in and the edit box settings decide how the fontstring is displayed. By default fontstrings will go across but if you limit the borders it can grow down. I suspect it uses that functionality in the Edit Box and needs the borders similarly limited.

I've not used multi line edit boxes myself so cannot confirm or rescind my ideas and with the servers down at present in the US for the next few hours I doubt I'll get to test it before I play in earnest later on.

If you still haven't got it figured out by tomorrow I will take a look and see if I can help figure it out. Although hopefully someone else can shed some more light on the subject.
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote
08-04-09, 02:26 PM   #5
xConStruct
A Chromatic Dragonspawn
 
xConStruct's Avatar
AddOn Author - Click to view addons
Join Date: May 2008
Posts: 199
e:IsMultiLine() will return the current state of the editBox, you're looking for e:SetMultiLine(bool). So basically your editBox still was one line big
__________________
« Website | GitHub »

Oh hai!
  Reply With Quote
08-04-09, 02:34 PM   #6
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,934
Originally Posted by Cargor View Post
e:IsMultiLine() will return the current state of the editBox, you're looking for e:SetMultiLine(bool). So basically your editBox still was one line big
D'oh, read right through that line and read it as SetMultiLine. Crazy how the brain reacts sometimes.
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote
08-18-09, 10:49 AM   #7
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
Code:
e:SetScript("OnEnterPressed", function() this:Insert("\n") end)
Instead of going to a new line, it just erases the single one and starts again.

Man, this is a pain in the ass.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » EditBox help needed


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