12.4 Examples of Menus and Dialogs in CLIM

12.4.3 Using :resynchronize-every-pass in accepting-values

It often happens that the programmer wants to present a dialog where the individual fields of the dialog depend on one another. For example, consider a spreadsheet with seven columns representing the days of a week. Each column is headed with that day's date. If the user inputs the date of any single day, the other dates can be computed from that single piece of input.

If you build CLIM dialogs using accepting-values, you can achieve this effect by using the :resynchronize-every-pass argument to accepting-values in conjunction with the :default argument to accept. There are three points to remember:

In this example we show a dialog that accepts two real numbers, delimiting an interval on the real line. The two values are labelledMin andMax, but we wish to allow the user to supply aMin that is greater than theMax, and automatically exchange the values rather than signalling an error.

(defun accepting-interval (&key (min -1.0) (max 1.0) 
                                (stream *query-io*)) 
  (clim:accepting-values (stream :resynchronize-every-pass t) 
                         (fresh-line stream) 
                         (setq min
                               (clim:accept
                                'clim:real :default min
                                :prompt "Min" :stream stream)) 
                         (fresh-line stream)
                         (setq max
                               (clim:accept
                                'clim:real :default max
                                :prompt "Max" :stream stream)) 
                         (when (< max min) 
                           (rotatef min max)))
  (values min max)) 
(You may want to try this example after dropping the :resynchronize-every-pass and see the behavior. Without :resynchronize-every-pass, the constraint is still enforced, but the display lags behind the values and doesn't reflect the updated values immediately.)


CLIM 2.0 User's Guide - OCT 1998

Generated with Harlequin WebMaker