When I have for example a checkbox in my tool top bar, its value gets reset when I switch to another tool and back.
Is it possible to save this state so that the value stays the same even if I switch to other tools inbetween?
Saving tool button states when switching between tools?
Moderators: Víctor Paredes, Belgarath, slowtiger
-
- Posts: 107
- Joined: Mon Jan 14, 2013 3:18 pm
- hayasidist
- Posts: 3511
- Joined: Wed Feb 16, 2011 8:12 pm
- Location: Kent, England
Re: Saving tool button states when switching between tools?
yes.
load and save prefs
for example
load and save prefs
for example
Code: Select all
function HS_Test_harness:SavePrefs(prefs)
prefs:SetBool("HS_Test_harness.trace", self.trace)
prefs:SetBool("HS_Test_harness.diagnose", self.diagnose)
prefs:SetFloat("HS_Test_harness.n1", self.n1)
prefs:SetFloat("HS_Test_harness.n2", self.n2)
prefs:SetString("HS_Test_harness.uut", self.uut)
end
function HS_Test_harness:LoadPrefs(prefs)
self.trace = prefs:GetBool("HS_Test_harness.trace", true)
self.diagnose = prefs:GetBool("HS_Test_harness.diagnose", true)
self.n1 = prefs:GetFloat("HS_Test_harness.n1", 0)
self.n2 = prefs:GetFloat("HS_Test_harness.n2", 0)
self.uut = prefs:GetString("HS_Test_harness.uut", defaultOn)
end
function HS_Test_harness:ResetPrefs()
self.trace = true
self.diagnose = true
self.n1 = 0
self.n2 = 0
self.uut = defaultOn
end
Last edited by hayasidist on Mon Mar 21, 2016 12:37 pm, edited 1 time in total.
-
- Posts: 107
- Joined: Mon Jan 14, 2013 3:18 pm
Re: Saving tool button states when switching between tools?
Thanks. Again.hayasidist wrote:yes.
load and save prefs
for exampleCode: Select all
function HS_Real_Time:SavePrefs(prefs) self.useIK = prefs:GetBool("HS_Real_Time.useIK", true) self.boneFBF = prefs:GetBool("HS_Real_Time.boneFBF", false) end function HS_Real_Time:LoadPrefs(prefs) prefs:SetBool("HS_Real_Time.useIK", self.useIK) prefs:SetBool("HS_Real_Time.boneFBF", self.boneFBF) end function HS_Real_Time:ResetPrefs() HS_Real_Time.useIK = true HS_Real_Time.boneFBF = false end
- hayasidist
- Posts: 3511
- Joined: Wed Feb 16, 2011 8:12 pm
- Location: Kent, England
Re: Saving tool button states when switching between tools?
error in original post -- updated -- please disregard the post to which you replied