Page 1 of 1
Saving tool button states when switching between tools?
Posted: Mon Mar 21, 2016 3:40 am
by lehtiniemi
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?
Re: Saving tool button states when switching between tools?
Posted: Mon Mar 21, 2016 4:32 am
by hayasidist
yes.
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
Re: Saving tool button states when switching between tools?
Posted: Mon Mar 21, 2016 4:33 am
by lehtiniemi
hayasidist wrote:yes.
load and save prefs
for example
Code: 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
Thanks. Again.

Re: Saving tool button states when switching between tools?
Posted: Mon Mar 21, 2016 4:38 am
by hayasidist
error in original post -- updated -- please disregard the post to which you replied