Re: A few more questions about sliders

From: Tim Gimmel <tjg_at_gimmel.org>
Date: Thu, 01 Jan 2009 14:14:13 -0600
To: Dmitry Karasik <dmitry_at_karasik.eu.org>

On Thu, 2009-01-01 at 12:06 +0100, Dmitry Karasik wrote:
> Hi Tim!
>
> Tim> Dmitry, I do not understand what you mean by "$self-> {my_last_value}
> Tim> = $self-> value"? The literal "my_last_value" does not exist. Do
> Tim> you mean "my $s = $self->value;", then $s is persistent? I'm
> Tim> confused!
Ok, I get it now, its an "anonymous hash". I did not understand this
until I did a little reading in the Perl books and read your last
message very carefully. Very handy these anonymous things! Here's the
code from onChange:

my $self = $_[0];
my ($curValue, $lastValue, $curFreq, $delta);
$curValue = $self->value;
$curValue *=.000001;
$curFreq = $myprogram::form->lblFreqDisp->text;
$lastValue = $self->{last_value};
$lastValue *= .000001;
if ($curValue >= $lastValue) {
            $delta = $curValue - $lastValue;
            $curFreq += $delta;
} elsif ($curValue <= $lastValue) {
            $delta = $lastValue - $curValue;
            $curFreq -= $delta;
}
setFreq('a', $curFreq);
print "sldFineTune::onChange: lastVaue = $lastValue\n";
$self->{last_value} = $self->value;

Note the last thing I do is set the "$self->{last_value}" for re-use
when the next onChange fires.

BTW, your suggestion on calling "scheme" fixed most of my slider label
problems, but have not tacked your suggestion on playing with the ticks
property. Looks like there needs to be a property to define the
distance between the border and the "outline" of the widget.

Thanks and HNY!
Tim

>
> No, the point is, that $s is _not_ presistent. In order to get a
> persistent storage, I propose a standard way to do that, store whatever
> value on the object itself.
>
> Tim> So all of my lexical variable can conflict with others lexicals?
> Tim> Doesn't make sense.
>
> I wouldn't use lexicals for this purpose. Either on-object storage,
> or a separate variable declared outside the handlers, in the main
> code section.
>
Received on Thu 01 Jan 2009 - 21:11:21 CET

This archive was generated by hypermail 2.2.0 : Sat 19 Mar 2011 - 18:35:06 CET