[plt-scheme] Odd slider% behaviour?

From: Andrew Reilly (andrew-scheme at areilly.bpc-users.org)
Date: Tue Sep 1 21:17:53 EDT 2009

Hi again,

Please consider this simple GUI program that seems to be a
minimal thing that demonstrates a problem that I'm having with
the GUI that I'm working on:

#lang scheme/gui

(let ((f (new frame% (label "SLIDER TEST"))))
  (new slider%
       (parent f)
       (label "foo")
       (min-value 0)
       (max-value 400)
       (init-value 200)
       (style '(horizontal horizontal-label plain))
       (min-height 50)
       (min-width 400)
       (callback
        (lambda (s e)
          (printf "~a ~a ~a~%" (send s get-label) (send s get-value) (send e get-event-type))
          (flush-output))))
  (send f show #t)
  (yield 'wait))

Without the callback, the slider pops up and one can wiggle
the control tab (thumb?) back and forth exactly as one might
expect.  Motion is continuous and responds instantly when the
mouse moves.  This is what I want to happen!

With the callback as shown (or the functionally similar thing in
my main program), the tab does not track mouse movement.
Instead, the tab will lurch from where it was to the location of
the mouse when the button is released, in one step.  Also, the
printouts show that the callback is called only twice for any
mouse-down/mouse-up pair.  If this down/up click is a "click" on
a location that isn't the tab, then the two events see a slider
in the "before" position and then the "after" position.  If the
down/up click is a "hold-and-slide" on the thumb, then the
slider value of both events reflects the "after" position.

What I *really* want is a stream of events that correspond to
the mouse movement in real-time, with the slider's thumb moving
continuously while held.  Just like it does without the
callback.  Is this possible?

I suspect that what I'm doing wrong is somehow mixing up the GUI
and standard-output event spaces, and running into interlocks
and/or timeouts somehow: there seems to be a significant lag
between the GUI activity and the log on the IDE console.  Should
I be putting the GUI into an indpendent thread, somehow?  If I
have a callback that just does (void) instead of (printf ...),
then the thumb continues to move smoothly.  I have yet to figure
out an intermediate callback structure that allows me to *use*
the real-time thumb movement...  (I'm trying to control a device
at the other end of a TCP/IP socket.)

I understand that the MrEd (#scheme/gui) functionality is built
on top of the WxWidgets library.  I've had a look at the slider
documentation in wxWidgets, and there seems to be a whole family
of "event types" that a slider can emit.  Do these show up
somehow in the event object?  The control-event% documentation
only admits to get-event-type -> 'slider (which is obvious in
this context), and get-time-stamp -> integer?, which I don't
really care about, I think.

Thanks in advance for any advice.

Cheers,

-- 
Andrew


Posted on the users mailing list.