Thread Tools Display Modes
02/01/19, 05:23 PM   #1
Letho
AddOn Author - Click to view addons
Join Date: Apr 2016
Posts: 238
Moving a control with

Hey guys, I need some help with the following task:



I want the icon to be dragable, but only by clicks inside the green square in it's top left corner.

If I apply SetMouseEnabled(true) and SetMovable(true) to the base control, the whole control will react to mouse clicks, not only the green square.

If I apply SetMouseEnabled(true) and SetMovable(true) to the green square, then only the green square reacts to mouse clicks, but the icon does not move with it despite being it's parent element.

This is the XML code:


Code:
<!-- Icon aura -->
<Control name="AM_IconAuraControl" virtual="true" clampedToScreen="true">
	<!--<Anchor point="TOPLEFT" relativeTo="AuraMasteryTLW" anchorPoint="TOPLEFT" />-->
	<Controls>
			
		<Control name="$(parent)_Anchor" hidden="true">
			<Dimensions x="12" y="12" />
			<Anchor point="TOPLEFT" relativeTo="$(parent)" anchorPoint="TOPLEFT" />
			<Controls>
				<Backdrop name="$(parent)_Backdrop" centerColor="FF00FF00" edgeColor="FF000000" level="2">
					<AnchorFill />
					<Edge edgeSize="1" /> 
				</Backdrop>
				<Label name="$(parent)_LabelCoords" font="$(BOLD_FONT)|16|soft-shadow-thin" color="00FF00" text="400,400">
					<Anchor point="TOP" relativeTo="$(parent)" anchorPoint="TOP" offsetY="-20" />	
				</Label>
			</Controls>
		</Control>
	
		<Backdrop name="$(parent)_Backdrop">
			<AnchorFill />
		</Backdrop>
		<Cooldown name="$(parent)_Cooldown" fillColor="000000BF" horizontalAlignment="TEXT_ALIGN_CENTER" verticalAlignment="TEXT_ALIGN_CENTER">
			<AnchorFill />
		</Cooldown>
		<Label name="$(parent)_Label">
			<Anchor point="TOPLEFT" relativeTo="$(parent)" anchorPoint="TOPLEFT" offsetX="2" offsetY="2" />
			<Anchor point="BOTTOMRIGHT" relativeTo="$(parent)" anchorPoint="BOTTOMRIGHT" offsetX="-2" offsetY="-2" />
		</Label>
		<Texture name="$(parent)_Icon">
			<AnchorFill />
		</Texture>
	</Controls>
</Control>

Last edited by Letho : 02/01/19 at 05:26 PM.
  Reply With Quote
02/01/19, 05:27 PM   #2
Rhyono
AddOn Author - Click to view addons
Join Date: Sep 2016
Posts: 659
What about adding a parent to it that is taller, so that you have a bar across the top that can move it? Not exactly what you're going for, but it's a fallback option.
  Reply With Quote
02/01/19, 08:13 PM   #3
Dolgubon
 
Dolgubon's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2016
Posts: 408
One option would be to set the anchor of the parent to be relative to the green square. For example,parent:SetAnchor(TOPLEFT, greenSquare, TOPLEFT, 0,0)


Another option (if that doesn't work) would be to use the OnMoveStart and OnMoveStop of the green square, and put something like:
EVENT_MANAGER:RegisterForUpdate("moving", 10, moveParentToGreenSquare)
  Reply With Quote
02/02/19, 01:03 AM   #4
Letho
AddOn Author - Click to view addons
Join Date: Apr 2016
Posts: 238
Originally Posted by Dolgubon View Post
One option would be to set the anchor of the parent to be relative to the green square. For example,parent:SetAnchor(TOPLEFT, greenSquare, TOPLEFT, 0,0)


Another option (if that doesn't work) would be to use the OnMoveStart and OnMoveStop of the green square, and put something like:
EVENT_MANAGER:RegisterForUpdate("moving", 10, moveParentToGreenSquare)
AH of course! The green square needs to be the parent, not the icon. I use the register function to update the coordinates in realtime when draging the control around.

Thanks for your help, guys!
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Moving a control with

Thread Tools
Display Modes

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