View Single Post
03/27/23, 11:17 PM   #33
sinnereso
AddOn Author - Click to view addons
Join Date: Oct 2022
Posts: 245
I do thank you very much for all your help. Its very difficult for me to know when what you type is directly the answer or random hypothetical and for me to research for days. I did spend the day on it and came up with this below because i had troule making sense of the panel and myPanel data.

Code:
------ Save player ------
function MyAddon.AddGGFContext(data)
	AddCustomMenuItem("Save to MyAddon", function() MyAddon.SavePlayer(data.displayName) end)
	return
end

function MyAddon.SavePlayer(displayName)
	MyAddon.savedVariables.savedPlayer = displayName
	df("|c6666FF[MyAddon]|r Saving: " .. tostring(displayName))
	if MyAddon_SETTINGS_SAVEDPLAYER_TEXT == nil then--<<< Checking if settings panel has been created
		CALLBACK_MANAGER:RegisterCallback("LAM-PanelControlsCreated", function(panel)
			if MyAddon_SETTINGS_SAVEDPLAYER_TEXT == nil then--<<< Checking if settings panel has been selected
				return
			else
				MyAddon_SETTINGS_SAVEDPLAYER_TEXT.data.text = "Saved Player: " .. tostring(displayName)
				MyAddon_SETTINGS_SAVEDPLAYER_TEXT:UpdateValue()
				return
			end
		end)
		return
	else
		MyAddon_SETTINGS_SAVEDPLAYER_TEXT.data.text = "Saved Player: " .. tostring(displayName)
		MyAddon_SETTINGS_SAVEDPLAYER_TEXT:UpdateValue()
		return
	end
end
this checks the actual description control that im editing in the panel. if it doesnt exist when user saves someone via context menu it saves the variable and registers the callback so when they open addon settings it updates the description field then.

if it does exist then it just saves variable and edits the description field as normal.

I couldnt find a reference that made sense to me for the panel but did have one for the description field so this worked perfectly i think.

What I have seems to work perfectly and is the last bug I can find so im gonna pump it out to the masses but.. i will research this more and look at your suggestion till im blue in the face and see if i can make it work soon.

Last edited by sinnereso : 03/27/23 at 11:29 PM.
  Reply With Quote