On Thu, 2 Mar 2017 03:32:08 -0800 (PST)
Alex Harsanyi <alexharsa...@gmail.com> wrote:

> You need to tell the snip admin that the snip needs to be redrawn.
> In your select-this-snip method, add
> 
>     (send (get-admin) needs-update this 0 0 width height)
> 

It still doesn't work. I'm using this:

 (define/public (select-this-snip)
      (define editor (send (get-admin) get-editor))
      (define pos (send editor get-snip-position this))
      (send editor set-position pos (+ pos 1))
      (define w (box 0))
      (define h (box 0))
      (get-extent (send (get-admin) get-dc) 0 0 w h)
      (send (get-admin) needs-update this 0 0 (unbox w) (unbox h)))

The snip *is* selected but not drawn as selected. The draw method
checks (pair? draw-caret) for determining whether its selected, and
this works for manual selection, i.e., left-click and mouse drag from
adjacent position.

Of course, I could work around this by maintaining my own selection
flag and resetting it in on-goodbye-event, but that seems like a hack
to me. Any ideas what I'm doing wrong?

Best,

Erich


----
My draw method:

    (define/override (draw dc x y left top right bottom dx dy
    draw-caret) (define-values (tw th tdist tvspace) (send dc
    get-text-extent (get-display-name)
                                                 (send (get-style)
    get-font) #t
                                                 0))
      (define w (+ tw 22))
      (define h (max 22 (+ th 4)))
      (define background-color
        (if (pair? draw-caret)
            (scale-color 0.8 (send (get-style) get-background))
            (send (get-style) get-background)))
      (define background
        (filled-rounded-rectangle
         w h
         #:color background-color
         #:border-color (scale-color 0.8 background-color)
         #:draw-border? #t))
      (define c-new (send (get-style) get-background))
      (define old-pen (send dc get-pen))
      (send dc set-smoothing 'aligned)
      (draw-pict background dc x y)
      (draw-pict (scale-to-fit (get-pict)
                               16
                               16)
                 dc (+ x 4) (+ y 4))
      (send dc set-pen old-pen)
      (when (and (pair? draw-caret) (get-highlight-text-color))
        (send dc set-text-foreground (get-highlight-text-color)))
      (send dc set-text-background background-color)
      (send dc draw-text (get-display-name) (+ x 20) (+ y 4) #t))

-- 
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