Thread Tools Display Modes
07-26-08, 04:16 PM   #1
korsibar
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 6
Help with multiline EditBox

Ok, if you put a multiline EditBox in a frame how do you prevent the text from going outside the frame? Right now I can type the command to bring up the frame with the EditBox and put in my input and it works fine. However, I can just keep pressing enter until the box spills outside the frame. I read on Wowwiki:

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.
I tried setting the top and bottom with SetPoint (might have done this wrong, but I tried following the example of how to use SetPoint). The text still goes outside the frame if I fill it up.
  Reply With Quote
07-26-08, 05:35 PM   #2
Macniel
A Fallenroot Satyr
 
Macniel's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2007
Posts: 26
You could probably just use a ScrollFrame Object with your multiline editbox as the scrollchild like it is mentioned on the corresponding Wiki page :

http://www.wowwiki.com/UIOBJECT_ScrollFrame
  Reply With Quote
07-26-08, 08:13 PM   #3
korsibar
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 6
Yes, I had a ScrollFrame before and didn't realize it would do what I wanted. I figured out I had forgotten to put the <ScrollChild> tags around the EditBox. The text was scrolling just fine before, but now it's messed up because my scrollbar update function was wrong.

I'm not sure how to do this because the wowwiki example showed how to make the scrollframe scroll through text being displayed from a table of data on "5 lines" by using 5 buttons. It's obviously going to be a different function when you're using a single EditBox.

I have (which does not work):

function EGScrollBar_Update()
local line;
local lineplusoffset;
local str
local str1=""

str = EGNote:GetText();

FauxScrollFrame_Update(EGScrollBar, table.getn(exc), 5, 12);
for line=1,5 do
lineplusoffset = line + FauxScrollFrame_GetOffset(EGScrollBar);
if lineplusoffset <= table.getn(exc) then
str1=str1.."\n"..exc[lineplusoffset]
EGNote:Show();
EGNote:SetText(str1);
else
EGNote:Hide();
end
end
end

Ok, so this kinda works but obviously is not right. With the code the way it is, I have a table exc which on addon load happens to have about 23 strings in it defined in the code. As I scroll down, it looks like it works at first, but when I get to around the 20th string (exc[20]) it has the visual effect of text eventually disappearing upwards until the box is empty. It should be displaying strings 21 and 22, but they are not being displayed and there is more room to move the scroll bar down but it's all blank. I have a bunch of things I've tried but none worked completely.

Is there a simple way to implement scrolling with an EditBox that I just don't know? Any ideas how to fix this?

I know how I could display the data using something like 5 buttons like wowwiki shows. I guess I just don't know how to write the update for an EditBox where the text is being entered/edited by the user as the box is scrolling.

Thanks for your help. Sorry if this post is confusing... I'm pretty confused.
  Reply With Quote
07-27-08, 02:16 AM   #4
Macniel
A Fallenroot Satyr
 
Macniel's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2007
Posts: 26
When you are using the UIPanelScrollFrameTemplate you do not need a update function because it redraws itself (like every ScrollFrame should after 2.3) you only need to anchor the top side from your Editbox to your ScrollFrame, and set the child to your Editbox. It only seems that you have to scroll manually to the bottom as you type in text.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Help with multiline EditBox


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