Greetings!
I was wondering if anyone could point me to a script that has a snippet of code to put a toggle button on the tool bar...
I'm trying to write a script to enable the play now but not continue option without having to go into the options menu.
I think I have the body of the code... But I'm lazy.
Toggle Button Code Snippet
Moderators: Gurus, Addon Administrators
Re: Toggle Button Code Snippet
Well in my "Monkey Rok" script the button is created in "onStartup" like this...
Then the rest of the relevant code (cut down a bit) looks like this...
Hope that helps
Code: Select all
Dim ini : Set ini = SDB.IniFile
ini.IntValue("MonkeyRok","OnIconIndex") = SDB.RegisterIcon("Scripts\MonkeyRok\monkeyrok_on.ico",0)
ini.IntValue("MonkeyRok","OffIconIndex") = SDB.RegisterIcon("Scripts\MonkeyRok\monkeyrok_off.ico",0)
Dim btn : Set btn = SDB.Objects("MonkeyRokButt")
If btn Is Nothing Then
Set btn = ui.AddMenuItem(ui.Menu_TbStandard,0,0)
btn.Caption = "MonkeyRok"
btn.IconIndex = ini.IntValue("MonkeyRok","OffIconIndex")
Set SDB.Objects("MonkeyRokButt") = btn
Call Script.RegisterEvent(btn,"OnClick","ToggleContextPanel")
End If
Code: Select all
Sub ToggleContextPanel(i)
If SDB.Objects("MonkeyRokPanel") Is Nothing Then
Call ShowContextPanel()
Exit Sub
End If
If SDB.Objects("MonkeyRokPanel").Common.Visible = False Then
Call ShowContextPanel()
Exit Sub
End If
Call HideContextPanel()
End Sub
Sub ShowContextPanel()
Dim but : Set but = SDB.Objects("MonkeyRokButt")
but.IconIndex = ini.IntValue("MonkeyRok","OnIconIndex")
but.Hint = "Hide MonkeyRok"
End Sub
Sub HideContextPanel()
Dim but : Set but = SDB.Objects("MonkeyRokButt")
but.IconIndex = ini.IntValue("MonkeyRok","OffIconIndex")
but.Hint = "Show MonkeyRok"
End Sub
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Re: Toggle Button Code Snippet
That looks like exactly what I need!
Many thanks!
Many thanks!