by trixmoto » Mon Jan 18, 2010 11:54 am
Well in my "Monkey Rok" script the button is created in "onStartup" like this...
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
Then the rest of the relevant code (cut down a bit) looks like this...
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
Hope that helps
Well in my "Monkey Rok" script the button is created in "onStartup" like this...
[code] 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]
Then the rest of the relevant code (cut down a bit) looks like this...
[code]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[/code]
Hope that helps :)