I have a subclass of list-box% which overrides on-size and calculates
relative column sizes based on get-client-size and some values provided
by an init variable.

However, if I don't check for "this" being an object, I get:

send: target is not an object
  target: #f
  method name: get-client-size

But despite the additional check I still sometimes get the error. Not
always, but most of the time. I also get it if I wrap
set-column-dimensions like this

(define (set-column-dimensions)
  (when this
     ...))

It also doesn't matter whether I call it as inherited method or as
(send this get-client-size).

How can I ensure that get-client-size works within on-size? Is
there a safe way to check that the GUI element is "graphically
initialized"?

Best,

Erich



 (define/override (on-size width height)
      (when (object? this)
        (set-column-dimensions)))

 (define/public (set-column-dimensions)
   (let-values (((w h) (get-client-size)))
     (for ([min-width (in-list minimum-widths)]
           [perc (in-list percentages)]
           [i (in-naturals)])
       (let* ((perc-width (truncate (* w (/ perc 100))))
              (actual-width (if (< perc-width min-width)
                               min-width
                               perc-width)))
         (set-column-width i actual-width
                           min-width
                           actual-width)))))

where minimum-widths and percentages are defined and set by an init
variable column-specs.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to