Thread Tools Display Modes
08/30/14, 09:06 AM   #1
Minceraft
 
Minceraft's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2014
Posts: 51
Angry SUCCESS!!!!....Sorta! But I'm proud!!!

So, through much trial and error, I got the Edit box to work! I now have a WORKING prototype..... The red box in the bottom left of the screen! Problem is, for some reason it isn't movable anymore.... mouseEnabled is true, movable is true..... SavedVariables loaded right...
I do like how the Default Text thing works and the :GetText() with the EditBox is an awesome way to do a variable!
Anyone have any ideas, please let me know!!
So, this is what I have so far for my xml....

<GuiXml>
<Controls>
<TopLevelControl name= "BOXUI" movable="true" mouseEnabled="true" clampedToScreen="true" alpha="1">
<OnMoveStop>
BOX.OnMoveStop(self)
</OnMoveStop>
<Controls>
<Backdrop name= "$(parent)Backdrop" inherits="ZO_DefaultBackdrop" edgeSize="2" edgeColor= "FF0000" alpha="0.8">

<Controls>
<EditBox name= "$(parent)Box" inherits= "ZO_DefaultEditForBackdrop ZO_EditDefaultText" >

<OnFocusGained>
ZO_EditDefaultText_Initialize(self, GetString(SI_DEFAULT_TEXT))
</OnFocusGained>

<OnEnter>
Jump()
</OnEnter>
</EditBox>
</Controls>
</Backdrop>
</Controls>
</TopLevelControl>
</Controls>
</GuiXml>

And this....
BOX = {}
BOX.name = "BOX"
BOX.version = "1.0"
BOX.settingsVersion ="1"

BOX.settingsDefaults = {

alpha=1;
movable = true;

wndMain = {
width = 210;
height = 30;
x= -500;
y= 505;
}
}

local AddonLoaded = false
ourName = GetUnitName("player")



function BOX.Initialize(eventCode, addOnName)
if (addOnName ~= BOX.name) then

return
end

AddonLoaded = true

BOX.settings = ZO_SavedVars:New("BOXVars", BOX.settingsVersion, nil, BOX.settingsDefaults, nil);

BOXUI:SetAnchor(BOTTOM, GuiRoot, CENTER, BOX.settings.wndMain.x, BOX.settings.wndMain.y);
BOXUI:SetWidth(BOX.settings.wndMain.width);
BOXUI:SetHeight(BOX.settings.wndMain.height);

BOXUI:SetAlpha(BOX.settings.alpha)
BOXUI:SetMovable(BOX.settings.movable)

ZO_CreateStringId("SI_BINDING_NAME_BOX", "BOX")
ZO_CreateStringId("SI_DEFAULT_TEXT","Type @Name and Hit Enter!")




return AddonLoaded

end

EVENT_MANAGER:RegisterForEvent( "BOX", EVENT_ADD_ON_LOADED, BOX.Initialize)

function BOX.OnMoveStop( self )
BOX.settings.wndMain.x = self:GetLeft();
BOX.settings.wndMain.y = self:GetTop();
BOX.settings.wndMain.width = self:GetWidth();
BOX.settings.wndMain.height = self:GetHeight();
end
Attached Thumbnails
Click image for larger version

Name:	Screenshot_20140830_095837.png
Views:	380
Size:	752.2 KB
ID:	450  

Last edited by Cairenn : 08/30/14 at 11:08 AM. Reason: Made attached screenshot smaller, no longer needs to be zipped ~ Cairenn
  Reply With Quote
08/31/14, 01:05 AM   #2
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
You should use the xml code tags & lua tags for your code.
Anyhow a couple of things I see...
First (this may be what you wanted) but do you realize your editbox is a child of the background & not the topLevelWindow (or it looks like that looking at what you posted).

You did not ClearAnchors() before anchoring your TLW.

You did not anchor your background or edit box to anything.

and you started with this:
Lua Code:
  1. BOX.settingsDefaults = {
  2.     alpha=1;
  3.     movable = true;
  4.     wndMain = {
  5.         width = 210;
  6.         height = 30;
  7.         x= -500;
  8.         y= 505;
  9.     }
  10. }
  11. -- and you anchored the TLW --
  12. -- You did not ClearAnchors() first, you should
  13. BOXUI:SetAnchor(BOTTOM, GuiRoot, CENTER, BOX.settings.wndMain.x, BOX.settings.wndMain.y);

You anchored the BOTTOM of the topLevelWindow to the Center of GuiRoot, which is fine, but then you replace your saved variable offsets with:
Lua Code:
  1. BOX.settings.wndMain.x = self:GetLeft();
  2. BOX.settings.wndMain.y = self:GetTop();
Left & Top are relative to the TOPLEFT corner of the GuiRoot. So the next time you load in your using those left & top saved variables as offsets when you anchor to the CENTER of GuiRoot again (so its not really going where its supposed to).

So although you see your edit box, where it is, the TopLevelWindow isn't really there. Since you didn't anchor your background & editbox to it they are probably getting separated.



Anchor the TOPLEFT of your TLW to to the TOPLEFT of GuiRoot.
Lua Code:
  1. -- Always ClearAnchors() first, before setting anchors
  2. BOXUI:ClearAnchors()
  3. BOXUI:SetAnchor(TOPLEFT , GuiRoot, TOPLEFT , BOX.settings.wndMain.x, BOX.settings.wndMain.y)

Then set anchors for your background & editbox. You can do it in xml or lua with
Lua Code:
  1. BOXUIBackdrop:ClearAnchors()
  2. BOXUIBackdrop:SetAnchor(TOPLEFT, BOXUI, TOPLEFT, 0, 0)
  3.  
  4. BOXUIBox:ClearAnchors()
  5. BOXUIBox:SetAnchor(TOPLEFT, BOXUI, TOPLEFT, 0, 0)
  6.  
  7. -- or  you may just want to use
  8.  
  9. BOXUIBackdrop:ClearAnchors()
  10. BOXUIBackdrop:SetAnchorFill(BOXUI)
  11.  
  12. BOXUIBox:ClearAnchors()
  13. BOXUIBox:SetAnchorFill(BOXUI)

SetAnchorFill will make them anchored to BOXUI & the same size as BOXUI.
  Reply With Quote
08/31/14, 09:56 PM   #3
Minceraft
 
Minceraft's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2014
Posts: 51
Ok....

So, I was messing around with these, like you suggested:

Lua Code:
  1. BOXUIBackdrop:ClearAnchors()
  2. BOXUIBackdrop:SetAnchorFill(BOXUI)
  3.  
  4. --This one works like a charm!! Makes it the same size as the main window, like you said!--
  5. --But then I tried to use this one to anchor the EditBox to the Backdrop.....--
  6.  
  7. BOXUIBox:ClearAnchors()
  8. BOXUIBox:SetAnchorFill(BOXUI)
  9. --it's expecting something instead of what it gets, I'm assuming, because it can't find it for some reason??--

I get what you were saying about the anchors needing to be cleared, though, because they are still anchored to the last point I set!
So, I'm guessing the (0, 0) on the other format are x and y? That could be really handy in other situations, as well.

But what about SavedVariables? This is what I'm using to remember where the window is....

Lua Code:
  1. function BOX.OnMoveStop( self )
  2.  
  3.  BOX.settings.wndMain.x = self:GetLeft();    
  4.   BOX.settings.wndMain.y = self:GetTop();    
  5.  --These work for my other Addons but not this one...  --
  6. --the others are movable perfectly and  they remain after ReloadUI--
  7.  BOX.settings.wndMain.width = self:GetWidth();
  8.   BOX.settings.wndMain.height = self:GetHeight();
  9.  
  10. end

What is the difference?And, I was looking around for examples of SavedVariable use but nothing seemed to match what I was needing...

The others are just textures and labels anchored to the tlw as well tho....
And Thanks for all your help, guys, I love this language but I'm just having a hard time with the computer part, hehe!!

I know there a way for me to just use just the xml to make the size of the box....but I couldn't get it to work...

Last edited by Minceraft : 08/31/14 at 10:11 PM. Reason: Added tags for lua and xml...
  Reply With Quote
09/02/14, 02:18 PM   #4
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
Originally Posted by Minceraft View Post
So, I was messing around with these, like you suggested:

Lua Code:
  1. BOXUIBackdrop:ClearAnchors()
  2. BOXUIBackdrop:SetAnchorFill(BOXUI)
  3.  
  4. --This one works like a charm!! Makes it the same size as the main window, like you said!--
  5. --But then I tried to use this one to anchor the EditBox to the Backdrop.....--
  6.  
  7. BOXUIBox:ClearAnchors()
  8. BOXUIBox:SetAnchorFill(BOXUI)
  9. --it's expecting something instead of what it gets, I'm assuming, because it can't find it for some reason??--
woops, my bad. This is because when I wrote that I expected (which is my own fault) the editBox to be a child of the TLW, but it is not. Your editBox is a child of the backdrop so I typed the wrong name. You do not have any control named: BOXUIBox.
Your editBox control is a child of the backdrop and named $(parent)Box.
The backdrop is a child of the TLW and is named: $(parent)Backdrop

So your editBox control is really named: BOXUIBackdropBox

So the second part, anchoring the editBox should have looked like this:
Lua Code:
  1. BOXUIBackdropBox:ClearAnchors()
  2. BOXUIBackdropBox:SetAnchorFill(BOXUI)


Originally Posted by Minceraft View Post
I get what you were saying about the anchors needing to be cleared, though, because they are still anchored to the last point I set!
So, I'm guessing the (0, 0) on the other format are x and y? That could be really handy in other situations, as well.
Yes the 0, 0 are the offsetX & offsetY from the anchor point.
Lua Code:
  1. BOXUIBackdrop:SetAnchor(TOPLEFT, BOXUI, TOPLEFT, OffsetX, OffsetY)



Originally Posted by Minceraft View Post
But what about SavedVariables? This is what I'm using to remember where the window is....
Lua Code:
  1. function BOX.OnMoveStop( self )
  2.  BOX.settings.wndMain.x = self:GetLeft();    
  3.   BOX.settings.wndMain.y = self:GetTop();    
  4.  --These work for my other Addons but not this one...  --
  5. --the others are movable perfectly and  they remain after ReloadUI--
  6.  BOX.settings.wndMain.width = self:GetWidth();
  7.   BOX.settings.wndMain.height = self:GetHeight();
  8. end

What is the difference?And, I was looking around for examples of SavedVariable use but nothing seemed to match what I was needing...
I don't know what your asking when you say what is the difference. The difference between what and what? I don't see anything wrong with that code you posted to save settings.

From what I remember & what I see here, I did not see any problems with how you were handling the saved variables. You have to get them all anchored properly first or they won't work regardless of how your handling the saved variables because your only restoring the position of the TLW in your code, which is the only window you cant actually see. If the others are not anchored to the TLW they will not necessarily be in the same spot as the TLW, so it will look like your saved variables (restoring the windows position) is not working...but it really is because the TLW is where it is supposed to be, where you told it to be. Its the other windows (background & edit box) that are not where they are supposed to be (anchored to the TLW).
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » SUCCESS!!!!....Sorta! But I'm proud!!!


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