Thread Tools Display Modes
05/21/14, 04:55 PM   #1
Tar000un
 
Tar000un's Avatar
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 47
Move a control from lua

Hi,

from http://www.esoui.com/forums/showthread.php?t=1541

i ve a lua code like the Clear / SetAnchor,

Code:
AddOnUI:ClearAnchors();
AddOnUI:SetAnchor( TOPLEFT, GuiRoot, TOPLEFT, 0, 0);
I ve also other control in. A texture and a label, with and anchorfill in a backdrop. I tryed to clear / set the backdrop without any success.

As exemple, see 1.2.{3.1,3.2}. Where 2:SetAnchor( _, 1, _,_,_);
I clear from 3.2, then 3.1, then 2, then 1 and reset in the first order.

But that works once and after my UI get bad offset (typically, my label go to the cursor), and UI's position isnt reset.
  Reply With Quote
05/21/14, 06:36 PM   #2
thelegendaryof
 
thelegendaryof's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 161
Originally Posted by Tar000un View Post
Hi,

from http://www.esoui.com/forums/showthread.php?t=1541

i ve a lua code like the Clear / SetAnchor,

Code:
AddOnUI:ClearAnchors();
AddOnUI:SetAnchor( TOPLEFT, GuiRoot, TOPLEFT, 0, 0);
I ve also other control in. A texture and a label, with and anchorfill in a backdrop. I tryed to clear / set the backdrop without any success.

As exemple, see 1.2.{3.1,3.2}. Where 2:SetAnchor( _, 1, _,_,_);
I clear from 3.2, then 3.1, then 2, then 1 and reset in the first order.

But that works once and after my UI get bad offset (typically, my label go to the cursor), and UI's position isnt reset.
I'm not sure if I understand you correctly - however like I've posted the other thread (deleted it there now since it was OT)
just reapply your above code in OnUpdate for every Frame (and dont forget the Buffer)

Last edited by thelegendaryof : 05/21/14 at 06:39 PM.
  Reply With Quote
05/21/14, 07:26 PM   #3
Stormknight
 
Stormknight's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2014
Posts: 128
I strongly advise against passing the variable _ to a function, unless you have declared it locally (assuming that's what you meant in the example).

It is commonly used as a "junk" variable so could contain any random value.
  Reply With Quote
05/22/14, 01:50 AM   #4
Tar000un
 
Tar000un's Avatar
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 47
I used _ to exprim "any variable you want put here".
2:SetAnchor( _, 1, _,_,_) have to be read like 2:SetAnchor( pos1, 1, pos2,offx,offy)

Originally Posted by thelegendaryof View Post
I'm not sure if I understand you correctly - however like I've posted the other thread (deleted it there now since it was OT)
just reapply your above code in OnUpdate for every Frame (and dont forget the Buffer)
I apply the code on a reset slash command. My purpose isnt to show a move (with multiple reset), but to redefine a position. Which is correctly reset... only one time per reloadUI. All next command doesnt work.
  Reply With Quote
05/22/14, 04:09 AM   #5
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
This depends on how your controls are defined, if you can post a few lines of code maybe we can figure out why controls does not want to move.
  Reply With Quote
05/22/14, 07:18 AM   #6
Tar000un
 
Tar000un's Avatar
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 47
The parts about the concerned code :

Lua Code:
  1. UI_Texture:ClearAnchors();
  2. UI_Label:ClearAnchors();
  3. UI_BG:ClearAnchors();
  4. UI:ClearAnchors();
  5.  
  6. UI:SetAnchor( TOPLEFT, GuiRoot, TOPLEFT, defaults.x, defaults.y );
  7. UI_BG:SetAnchor(TOPLEFT, UI, TOPLEFT, 0, 0);
  8. UI_Texture:SetAnchor(TOPLEFT, UI_BG, TOPLEFT, 0, 0);
  9. UI_Label:SetAnchor(BOTTOM, UI_BG, BOTTOM, 0, 0);



The XML:
Code:
<Controls>
	<Backdrop name="$(parent)_BGcompassTiny" 
			inherits="ZO_CenterlessBackdrop" edgeColor="000000" 
			centerColor="000000" alpha="0">
		<AnchorFill />
	</Backdrop>
	<Texture name="$(parent)_TextureCompassTiny" />
	<Label name="$(parent)_LabelCompassTiny" 
		verticalAlignment="BOTTOM" horizontalAlignment="CENTER" 
		text="Label" alpha="1" 
	/>
</Controls>
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Move a control from lua


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