Thread Tools Display Modes
10-19-05, 08:52 AM   #1
shouryuu
A Chromatic Dragonspawn
 
shouryuu's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2005
Posts: 150
Moving a frame

Shouldn't a simple
FrameName:RegisterForDrag("RightButton");
work?

For example:
PlayerFrame:RegisterForDrag("RightButton")
  Reply With Quote
10-19-05, 10:21 AM   #2
Gello
A Molten Giant
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 521
If you register for a drag, you also need <OnDragStart> and <OnDragStop>. And within you'll need to StartMoving and StopMovingOrSizing.

When something is dragged, the mouse needs to move off the element while the button is down. For moving whole dialog frames this isn't a good method. Most just react to OnMouseDown and OnMouseUp:

<Scripts>
<OnMouseDown>
if arg1=="LeftButton" then this:StartMoving() end
</OnMouseDown>
<OnMouseUp>
if arg1=="LeftButton" then this:StopMovingOrSizing() end
</OnMouseUp>
</Scripts>

to do it with drag events:

<Scripts>
<OnLoad>
this:RegisterForDrag("LeftButton")
</OnLoad>
<OnDragStart>
this:StartMoving()
</OnDragStart>
<OnDragStop>
this:StopMovingOrSizing()
</OnDragStop>
</Scripts>

But for single elements like buttons definitely Drag is a better way to move than mouse down/up.
  Reply With Quote
10-19-05, 10:29 AM   #3
shouryuu
A Chromatic Dragonspawn
 
shouryuu's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2005
Posts: 150
Thanks man, you really are saving my ass
  Reply With Quote
10-19-05, 10:54 AM   #4
Gello
A Molten Giant
AddOn Author - Click to view addons
Join Date: Jan 2005
Posts: 521
hehe np. An interesting trick with StartMoving etc is you can move other frames from other frames.

MoveAnything and the Discord equivalent do the job well enough that there's no need, but one addon idea I had was a little "tug boat" button that you dragged around the screen with the left button, then when you did a OnDragStart (with right button registered) it would hide the tug boat to get the name of the window beneath, then StartMoving that window and stop when you let go.

So you could (in theory) move any window without knowing its name.
  Reply With Quote
10-19-05, 11:18 AM   #5
shouryuu
A Chromatic Dragonspawn
 
shouryuu's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2005
Posts: 150
Well that's a rather cool idea... MoveAnything does that for you, but I'm guessing your idea I far more "script-saving" than move anything... You'd have that script you gave me with an extra
local frame = MouseOver:GetName()

and we're set to move any frame... That is really cool.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Moving a frame


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