Quantcast Slash Command Opening Frame - WoWInterface
Thread Tools Display Modes
08-11-18, 09:47 PM   #1
candrid
Premium Member
 
candrid's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 58
Slash Command Opening Frame

Hi Guys,

I am trying to learn by hand and research but I am a little stuck and have to take steps in very small amounts do to an injury.

I am trying to make a slash command, that toggles a frame on and off. The command like "/paw" would open up a normal frame, created by lua. I have a feeling it has something to do with EventRegister?

I can't seem to fit it together in my head.
Any tips?
  Reply With Quote
08-11-18, 10:05 PM   #2
Ammako
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Jun 2016
Posts: 256
Wowpedia has a good example on that.

https://wow.gamepedia.com/Creating_a_slash_command

Depending on which frame it is you're looking to toggle on and off, it should be as simple as adding if not frame:IsShown() then frame:Show() else frame:Hide() end in your handler function (replacing "frame" with the frame in question, of course.)

Not sure if :IsVisible() or :IsShown() would be preferable, you might have to experiment. Or someone probably knows. But since you'd be calling :Show() and :Hide() on that very same frame, :IsShown() should work fine.

Last edited by Ammako : 08-11-18 at 10:09 PM.
  Reply With Quote
08-11-18, 10:16 PM   #3
Kanegasi
A Frostmaul Preserver
 
Kanegasi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2007
Posts: 284
The IsShown method checks whether the frame would be shown, such as its parent is shown. IsVisible is a direct check on whether the frame is actually visible. If IsVisible is true, IsShown is always true, but IsVisible can be false while IsShown is true.

Neither account for 0 alpha or frame position being off screen.
  Reply With Quote
08-11-18, 11:09 PM   #4
candrid
Premium Member
 
candrid's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 58
Thanks guys Ill take a good look at this.
  Reply With Quote
08-11-18, 11:21 PM   #5
candrid
Premium Member
 
candrid's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 58
Lua Code:
  1. local BottomPane = CreateFrame("Frame", "BottomPane", nil, UIParent) -- creates a frame named BottomPane. Note, we also set a variable called bottompane.
  2. BottomPane:SetFrameStrata("LOW");
  3. ScreenW = GetScreenWidth();
  4. ScreenH = GetScreenHeight();
  5. BottomPane:SetWidth(ScreenW);
  6.  
  7. local BPTex = BottomPane:CreateTexture(nil, "BACKGROUND");
  8. BPTex:SetTexture("Interface\\Addons\\PawsUI\\Art\\splash.tga");
  9. BPTex:SetAllPoints(BottomPane);
  10. BottomPane.texture = BPTex
  11. BottomPane:SetPoint("BOTTOM",0,0)
  12. BottomPane:Show();
  13.  
  14. SLASH_PANE1 = "/pane"
  15. SlashCmdList.PANE = function(arg)
  16.     if not BottomPane:IsShown() then
  17.       BottomPane:Show()
  18.     else BottomPane:Hide()
  19.     end
  20. end


Ok fixed the lua errors. Nothing happens but I think it is the tga.

Last edited by candrid : 08-11-18 at 11:59 PM.
  Reply With Quote
08-11-18, 11:30 PM   #6
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 931
The frame didn't have any height and a few other errors

Code:
local BottomPane = CreateFrame("Frame", "BottomPane", nil, UIParent) -- creates a frame named BottomPane. Note, we also set a variable called bottompane.
ScreenW = GetScreenWidth();
ScreenH = GetScreenHeight();
BottomPane:SetWidth(ScreenW);
BottomPane:SetHeight(50)

local BPTex = BottomPane:CreateTexture(nil, "BACKGROUND");
BPTex:SetTexture("Interface/BUTTONS/WHITE8X8");
BPTex:SetAllPoints(BottomPane);
BottomPane.texture = BPTex
BottomPane:SetPoint("BOTTOM",0,0)

SLASH_PANE1 = "/pane"
SlashCmdList.PANE = function(arg)
    BottomPane:SetShown(not BottomPane:IsShown())
end
OVERLAY is not a Strata
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle and Move Pad Plus.

Last edited by Fizzlemizz : 08-11-18 at 11:34 PM.
  Reply With Quote
08-11-18, 11:50 PM   #7
candrid
Premium Member
 
candrid's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 58
Originally Posted by Fizzlemizz View Post
SLASH_PANE1 = "/pane"
SlashCmdList.PANE = function(arg)
BottomPane:SetShown(not BottomPane:IsShown())
end
Sorry for my ignorance. How would I make it not show by default? I managed to replicate the toggle.
  Reply With Quote
08-11-18, 11:53 PM   #8
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 931
Lua Code:
  1. local BottomPane = CreateFrame("Frame", "BottomPane", UIParent)
  2. BottomPane:Hide()
  3. ...

The nil in your CreateFrame statement was incorrect, the third parameter is the parent.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle and Move Pad Plus.

Last edited by Fizzlemizz : 08-11-18 at 11:57 PM.
  Reply With Quote
08-12-18, 12:01 AM   #9
candrid
Premium Member
 
candrid's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Aug 2008
Posts: 58
Originally Posted by Fizzlemizz View Post
Lua Code:
  1. local BottomPane = CreateFrame("Frame", "BottomPane", UIParent)
  2. BottomPane:Hide()
  3. ...

The nil in your CreateFrame statement was incorrect, the third parameter is the parent.
Wow. First off, you are a Legend, I used to use your UI when it was new. It was revolutionary. Second, thank you so much for the help, I think I understand this switch now. Third, I even learned how to color my code on the forums! Thanks!
  Reply With Quote
08-12-18, 12:06 AM   #10
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 931
Originally Posted by candrid View Post
Wow. First off, you are a Legend, I used to use your UI when it was new.
You're probably thinking of the original, mine is just a pale imitation so, not so legendary . Have fun.
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle and Move Pad Plus.
  Reply With Quote
08-12-18, 10:17 AM   #11
JDoubleU00
An Onyxian Warder
 
JDoubleU00's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 356
Originally Posted by Fizzlemizz View Post
You're probably thinking of the original, mine is just a pale imitation so, not so legendary . Have fun.
Maybe not legendary, but Epic (purple)?
__________________
Author of JWExpBar and JWRepBar.
  Reply With Quote
08-12-18, 10:32 AM   #12
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 931
Mostly green with occaisional leaps into the blue... this can't end anywhere good .
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle and Move Pad Plus.
  Reply With Quote
08-12-18, 11:00 AM   #13
Ammako
A Frostmaul Preserver
AddOn Author - Click to view addons
Join Date: Jun 2016
Posts: 256
But Epics are the new Greens
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » Slash Command Opening Frame

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