View Single Post
02-20-24, 01:05 AM   #6
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,894
I have no idea what code you're testing so, as a standalone example of a button that can be dragged and saved.

Lua Code:
  1. local btn = CreateFrame("Button", "Hubb777MovingButton", UIParent, "UIPanelButtonTemplate")
  2. btn:SetPoint("CENTER")
  3. btn:SetSize(100, 40)
  4. btn:SetText("Click me")
  5. btn:SetScript("OnClick", function(self, button, ...) print("I've been clicked!") end)
  6. btn:SetMovable(true)
  7. btn:RegisterForDrag('LeftButton')
  8. btn:SetUserPlaced(true) -- Only works if the frame is created before the PLAYER_LOGIN event
  9. btn:SetScript('OnDragStart', btn.StartMoving)
  10. btn:SetScript('OnDragStop', btn.StopMovingOrSizing)
  11. btn:RegisterForClicks("AnyUp")

You will have to move the pieces into your addon. Possibly just the btn:SetUserPlaced(true) and giving the button a name.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 02-20-24 at 01:10 AM.
  Reply With Quote