Thread Tools Display Modes
01-15-15, 04:14 PM   #21
Sweetsour
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Dec 2014
Posts: 130
I found the element's name via hovering over it with /framestack. Is there [API] documentation for LibDBIcon? I couldn't find anything in a google search
  Reply With Quote
01-15-15, 04:20 PM   #22
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
http://www.wowace.com/addons/libdbicon-1-0/
__________________
"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
01-15-15, 04:20 PM   #23
Sweetsour
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Dec 2014
Posts: 130
Thanks!
  Reply With Quote
01-15-15, 09:43 PM   #24
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by Sweetsour View Post
Is there a way I can access the element (the minimap button) to have the ability to set its point using :SetPoint() (outside of this code)?
You should really not be doing that. Why do you need to move the minimap button independently of the user?

If you just want to provide your own options for moving the button around the minimap instead of just letting the user click and drag it, just modify the "minimapPos" value (it's an angle) in your settings table (the one you passed to LibDBIcon) and then tell the library to refresh.

I think there used to be better documentation, but the following methods are available:

lib:Register(name, object, db)
- name: string, should just use the same name you gave LibDataBroker
- object: table, same one you gave LibDataBroker, which is also what LDB:NewDataObject returns a ref for
- db: table, should be in your SavedVariables somewhere, will store info on whether the button should be shown/hidden, and where around the minimap to show it

lib:Lock(name)
lib:Unlock(name)

Disable or enable dragging to move the specified button. Stored as a boolean under the "lock" key in the db.

lib:Hide(name)
lib:Show(name)

Hide or show the specified button. These methods don't store the state in the db; set a boolean under "hide" yourself.

lib:IsRegistered(name)
Exactly what it sounds like. Not really any reason to use this method in addons.

lib:Refresh(name, db)
Refreshes the visibility, position, and lock state of the button. If "db" is provided, it overwrites the previous one; this is intended for use with eg. AceDB-3.0 profile switches. If "db" is not provided, it uses the one given with :Register. This is all done automatically when you :Register, so you only need to call this after modifying db values yourself.

lib:GetMinimapButton(name)
Gets a reference to the actual button object. You should generally not use this unless you want to do something like change the button appearance. If you want to move/hide/lock the button, use the appropriate lib methods instead.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.

Last edited by Phanx : 01-15-15 at 09:55 PM. Reason: Add lib info
  Reply With Quote
01-16-15, 05:12 PM   #25
Sweetsour
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Dec 2014
Posts: 130
Great documentation, Phanx!

I was trying to figure out how to keep the minimap in its same position between sessions. After some reading, I realized I wasn't using a piece of code correctly.

Lua Code:
  1. -- I didn't put the correct saved variable (WBi_SavedVar) at first
  2. WBi.ldbIcon:Register(name, WBiLauncher, WBi_SavedVar)
  Reply With Quote
01-17-15, 02:52 AM   #26
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
If your main saved variable is already a table, you can just use a sub-table in it instead of adding a second saved variable; eg. in Grid I do something like this:

Code:
Grid.db.profile = {
     -- bunch of settings here
     minimap = {},
}

LibDBIcon:Register("Grid", GRID_LDB_OBJECT, Grid.db.profile.minimap)
This is also an example of where the :Refresh method is useful -- when the user switches their profile, I need to call :Register with a reference to the "minimap" sub-table in the new profile table.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Minimap Button Tooltip


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