Thread Tools Display Modes
09-30-19, 08:09 PM   #1
mtp1032
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Jan 2006
Posts: 22
HOWTO: Drag and Drop To An Options Menu?

I have an addon that can be configured to sell items by quality (common, uncommon, rare, epic) and/or container (i.e., all items in the selected bags will be sold regardless of quality). All this works perfectly. But now I want to add the ability exclude selected items by dragging (PickupContainerItem()) and dropping the item(s) onto the addon's options' menu and into an exceptions list. All items on the exceptions list will not and cannot be sold.

Since I"m not "moving" an item from one location (e.g., a bag slot) to another (e.g., a bank slot) but to an options menu, how would I accomplish this.

Thanks, in advance, for any suggestions.
  Reply With Quote
09-30-19, 10:59 PM   #2
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 666
I'm not familiar with the "official" way to drag and drop items, but something like this should work:

Lua Code:
  1. frame:SetScript("OnClick",function(
  2.     -- GetCursorInfo()
  3.     -- ClearCursor()
  4. end)

This is just a thought process. I don't know if the cursor item clears on any click not on the world frame (which triggers the delete), but if it does, you may need to temporarily cache what the info returns in an OnEnter script then submit the item to your list on the click.
  Reply With Quote
10-01-19, 02:31 PM   #3
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
I would do it on MouseUp
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
10-01-19, 02:57 PM   #4
mtp1032
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Jan 2006
Posts: 22
Seriously, is it that simple? So on MouseUp the code would

(1) Get the item link held by the cursor
(2) Clear the cursor
(3) Execute the necessary code to insert the item into the exception list.

Do I not need to verify that the mouse is hovering over a specified region of the AddOn Options Dialog? What if the user accidently / inadvertanly releases the button over another slot in another bag? Or in open space (as when deleting an item)?

I hope it's as easy as this.

Cheers,
  Reply With Quote
10-01-19, 09:01 PM   #5
Kanegasi
A Molten Giant
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 666
The "frame" in my example is your addon's options frame, or even a specific colored box within your options.

Lua Code:
  1. local myframe=CreateFrame("frame")
  2. -- frame sizing, parenting, texture, color, etc
  3. myframe:SetScript("OnMouseUp",function(self,button)
  4.     -- the cursor info and clear here
  5.     -- button == "LeftButton" or "RightButton"
  6. end)

The code will do nothing if the user doesn't release the item over this specific frame. No need to check for any other location.
  Reply With Quote
10-02-19, 07:37 AM   #6
mtp1032
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Jan 2006
Posts: 22
I see. Thanks, Kanegasi, I didn't know that about frame-button semantics.

Cheers,
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » HOWTO: Drag and Drop To An Options Menu?

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