Thread Tools Display Modes
10-13-05, 11:30 AM   #1
Vex
Premium Member
 
Vex's Avatar
Join Date: Sep 2005
Posts: 41
TitanPanel, toggling frame visibility ?

First time making a mod, and its to toggle frame visibility instead of having to type the /slash commands to bring them up.


I'm at a loss, and looked everywhere.

here's my code :

Code:
function ToggleTitanDiscordFrame(frame)
if(frame:IsVisible()) then 
	frame:Hide();
else
	frame:Show();
end
end

-- under the rightclickmenu prepare

TitanPanelRightClickMenu_AddCommand("Discord Action Bars", TITAN_DISCORD_ID,ToggleTitanDiscordFrame(DAB_Options));
the problem is, the frame shows up before i even open the rightclick menu, and it doesnt toggle at all whatsoever. once its open, its open, the TitanPanelRightclickMenu option doesnt use the function ;(
  Reply With Quote
10-13-05, 12:04 PM   #2
shouryuu
A Chromatic Dragonspawn
 
shouryuu's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2005
Posts: 150
Humm not sure but might be the fact that one condition being true, leads the to other to be true as well, which leads the first one to be true and so forth... I doubt that its the problem but the simple IF statement seems wrong to me... To my eyes it'll do the following:
At first the frame is shown
IF is shown THEN hide so it's hiddent but since
IF hidden then show well it's shown again.

I would do the following ( The frame is shown by default)
Code:
Toggle_val = 1

function ToggleTitanDiscordFrame(frame)
if(frame:IsVisible() and Toggle_val == 1) then 
	frame:Hide(); 
        Toggle_val = 0
elseif Toggle_val == 1 then
	frame:Show();
end
Toggle_val = 1
end
The frame is visible by default, so (frame:IsVisible() and Toggle_val == 1) will return true, so it will hide it and set toggle_val to 0. Then it checks the second condition, Toggle_val == 1, which will return false, so it won't show the frame. Then the function sets Toggle_val to 1 again. So now the frame is hidden and toggle_val is equal to 1. You use the function again, but this time (frame:IsVisible() and Toggle_val == 1) will return false since the framse is hidden, but Toggle_val == 1 will return true since we set it to 1 the ast time we used the funciton, so it will hide the frame.

Hope that is the answer to your problems. Good luck!
  Reply With Quote
10-13-05, 12:09 PM   #3
Vex
Premium Member
 
Vex's Avatar
Join Date: Sep 2005
Posts: 41
Code:
Toggle_val = 1

function ToggleTitanDiscordFrame(frame)
	if(frame:IsVisible() and Toggle_val == 1) then 
		frame:Hide(); 
        		Toggle_val = 0
	elseif Toggle_val == 1 then
		frame:Show();
	end
	Toggle_val = 1
end

function TitanPanelRightClickMenu_PrepareDiscordMenu()
	TitanPanelRightClickMenu_AddTitle(TitanPlugins[TITAN_DISCORD_ID].menuText);

	TitanPanelRightClickMenu_AddCommand("Discord Action Bars", TITAN_DISCORD_ID,ToggleTitanDiscordFrame(DAB_Options));
it does the exact same thing. the rightclickmenu option refuses to toggle the visibility of the frame.

i dont want the frame to start off visible. i want it to become visible when the option in the rightclick menu is clicked.

rightclicking the actual button on the titan panel will hide/show it, but thats not what i wanted either
  Reply With Quote
10-13-05, 01:28 PM   #4
Vex
Premium Member
 
Vex's Avatar
Join Date: Sep 2005
Posts: 41
i give up.

i've figured out that the options directly control the button on the TitanPanel rather than do a command independent of that button.

Code:
TITAN_DISCORD_ID = "Discord";

function TitanPanelDiscordButton_OnLoad()
	this.registry = {
		id = TITAN_DISCORD_ID,
		menuText = "Discord Options",
		tooltipTitle = "Discord Options", 
		tooltipTextFunction = "TitanPanelDiscordButton_GetTooltipText",
		buttonTextFunction = "TitanPanelDiscordButton_GetButtonText",
		icon = "Interface\\Addons\\DiscordArt\\CustomTextures\\discordminimap.tga",	
		iconWidth =16,
		savedVariables = {
			ShowIcon = 1,
			ShowLabelText = 1,
		}
	};	
end

function TitanPanelDiscordButton_GetTooltipText()
	return "Toggle Discord Mod Options Windows";
end

function TitanPanelDiscordButton_GetButtonText()
	return "Discord";
end

function TitanPanelRightClickMenu_PrepareDiscordMenu()
	TitanPanelRightClickMenu_AddTitle(TitanPlugins[TITAN_DISCORD_ID].menuText);

	info = {};
	info.text = "Discord Action Bars";
	info.value = TITAN_DISCORD_ID;
	info.func = DAB_Options:Show();
	UIDropDownMenu_AddButton(info, level);

	info = {};
	info.text = "Discord Unit Frames";
	info.value = TITAN_DISCORD_ID;
	info.func = DUF_Options:Show();
	UIDropDownMenu_AddButton(info, level);
	

	TitanPanelRightClickMenu_AddSpacer();	
	TitanPanelRightClickMenu_AddToggleIcon(TITAN_DISCORD_ID);
	TitanPanelRightClickMenu_AddToggleLabelText(TITAN_DISCORD_ID);	
	TitanPanelRightClickMenu_AddSpacer();
	TitanPanelRightClickMenu_AddCommand(TITAN_PANEL_MENU_HIDE, TITAN_DISCORD_ID, TITAN_PANEL_MENU_FUNC_HIDE);
end
thats my .lua file
  Reply With Quote
10-13-05, 02:39 PM   #5
shouryuu
A Chromatic Dragonspawn
 
shouryuu's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2005
Posts: 150
rightclicking the actual button on the titan panel will hide/show it, but thats not what i wanted eithe
That's what I understood you wanted to do Sorry I couldn't help more, I'm not much of a programmer...
  Reply With Quote
10-13-05, 02:49 PM   #6
Vex
Premium Member
 
Vex's Avatar
Join Date: Sep 2005
Posts: 41
well im wanting a toggle list of opening about 5 different option windows.

just going to turn it into yet another minimap button.
  Reply With Quote
10-13-05, 03:11 PM   #7
shouryuu
A Chromatic Dragonspawn
 
shouryuu's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2005
Posts: 150
That did not make sens to me. You want to make a function so that when you right click on a certain button, a list appears under the button?
  Reply With Quote
10-13-05, 04:05 PM   #8
Vex
Premium Member
 
Vex's Avatar
Join Date: Sep 2005
Posts: 41
yeah, the popup menu frame will list 5 or so items that will toggle an options frame.

Basically,

Discordmods.com has a few amazing addons, but right now, you have to type in a slash command to open the options window.

I'd like to make it so there's a TitanPanel addon that lets you pick which optionwindow to view. Its just refusing to open 1 at a time, and on-demand. It likes to open all of them when the UI loads, regardless whether or not the Discordbutton is on the titanpanel in the first place.

want me to zip up my addon and send it to you for you to see what it does?
  Reply With Quote
10-13-05, 05:17 PM   #9
shouryuu
A Chromatic Dragonspawn
 
shouryuu's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2005
Posts: 150
Well my coding skills are really awful... I've never written an add on in my life so I doubt I'll be much help. I can give it a try if you want but I strongly doubt I'll be of any help ( my account expired as well so I won't be able to test any of what I write...). You can always put a link up (try puting one in the XML forum as well) and hope someone more qualified comes by
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » TitanPanel, toggling frame visibility ?


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