08/30/14, 09:06 AM | #1 |
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 Last edited by Cairenn : 08/30/14 at 11:08 AM. Reason: Made attached screenshot smaller, no longer needs to be zipped ~ Cairenn |
|
08/31/14, 01:05 AM | #2 |
|
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:
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:
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:
Then set anchors for your background & editbox. You can do it in xml or lua with Lua Code:
SetAnchorFill will make them anchored to BOXUI & the same size as BOXUI. |
08/31/14, 09:56 PM | #3 |
Ok....
So, I was messing around with these, like you suggested:
Lua Code:
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:
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... |
|
09/02/14, 02:18 PM | #4 | |||
|
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:
Lua Code:
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). |
|||
ESOUI » Developer Discussions » Lua/XML Help » SUCCESS!!!!....Sorta! But I'm proud!!! |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|