set internal value before drawing.

setting value directly will change visual.
small change
fixed bug of compilation error on Mac