Hi, I edited your sample a little so I could run it here. But in both situations the CPU utilization remains very low all the time.
I'm sending the complete sample attached. Please, compare it to your original script. Best, Scuri > -----Original Message----- > From: Victor Bombi [mailto:[email protected]] > Sent: segunda-feira, 27 de janeiro de 2014 12:01 > To: IUP discussion list. > Subject: [Iup-users] valuechanged_cb mistery > > Hello, > > I needed a not modal dialog so i could not use iupGetParam. > I made a function to be called as > > NM = NotModal(function() iup.Update(cnv) end, > { > {"angle",0.0,iup.dial,{orientation="CIRCULAR"}}, -- > name,default,creation,arguments > {"zcam",50,iup.val,{min=0,max=500}}, > {"radspersecond",math.pi,iup.dial,{orientation="CIRCULAR"}}, > {"fogDensity",0,iup.val,{min=0,max=0.005}} > }) > > and then use NM.fogDensity to know actual value. > > Every time I used sliders CPU time got worse and did not go down when > stoping interaction. > This problem disappeared when I changed > > function ctrl:valuechanged_cb() > labelval.title = self.value ; > this[name] = self.value; > fun(name,self.value) > end > > for > > function ctrl:mousemove_cb(val) > labelval.title = val ; > this[name] = val; > fun(name,val) > end > > It seems that the relevant line is this[name] = self.value; > > Here are both versions > --------------------good one > function NotModal(fun,telems) > local elems = {} > local this = {} > this.vars = {} > for i,elem in ipairs(telems) do > local name = elem[1] > local inival = elem[2] > local verb = elem[3] > local args = elem[4] or {} > local label = iup.label{title=name} > local labelval = iup.label{title=tostring(inival),size = "100x10"} > local ctrl = verb(args) > function ctrl:mousemove_cb(val) > labelval.title = val ; > this[name] = val; > fun(name,val) > end > ctrl.value = inival > this[name] = inival > this.vars[#this.vars + 1] = {name = name, ctrl = ctrl, inival = inival} > elems[i] = iup.hbox{label,ctrl,labelval} > end > local butreset = iup.button{title="Reset"} > function butreset:action() > for i,var in ipairs(this.vars) do > var.ctrl:mousemove_cb(var.inival) > end > end > elems[#elems + 1] = butreset > this.dialog = iup.dialog{iup.vbox(elems),topmost="YES"} > this.dialog:show() > return this > end > -------------problematic one > function NotModal(fun,telems) > local elems = {} > local this = {} > this.vars = {} > for i,elem in ipairs(telems) do > local name = elem[1] > local inival = elem[2] > local verb = elem[3] > local args = elem[4] or {} > local label = iup.label{title=name} > local labelval = iup.label{title=tostring(inival),size = "100x10"} > local ctrl = verb(args) > function ctrl:mousemove_cb(val) > labelval.title = val ; > this[name] = val; > fun(name,self.value) > end > ctrl.value = inival > this[name] = inival > this.vars[#this.vars + 1] = {name = name, ctrl = ctrl, inival = inival} > elems[i] = iup.hbox{label,ctrl,labelval} > end > local butreset = iup.button{title="Reset"} > function butreset:action() > for i,var in ipairs(this.vars) do > var.ctrl:mousemove_cb(var.inival) > end > end > elems[#elems + 1] = butreset > this.dialog = iup.dialog{iup.vbox(elems),topmost="YES"} > this.dialog:show() > return this > end > > ----------------------- > why is this happening? I wish iupVal:mousemove_cb() dont gets > deprecated!!! > > Best Regards > victor bombi > > > > ---------------------------------------------------------------------------- -- > CenturyLink Cloud: The Leader in Enterprise Cloud Services. > Learn Why More Businesses Are Choosing CenturyLink Cloud For > Critical Workloads, Development Environments & Everything In Between. > Get a Quote or Start a Free Trial Today. > http://pubads.g.doubleclick.net/gampad/clk?id=119420431&iu=/4140/ostg.c > lktrk > _______________________________________________ > Iup-users mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/iup-users
test.lua
Description: Binary data
------------------------------------------------------------------------------ Managing the Performance of Cloud-Based Applications Take advantage of what the Cloud has to offer - Avoid Common Pitfalls. Read the Whitepaper. http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk
_______________________________________________ Iup-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/iup-users
