[racket] newb question - image-snip and adjust-cursor

From: Joseph DiMuro (joseph.dimuro at biola.edu)
Date: Mon Jul 14 00:32:39 EDT 2014

Robby, thanks for the help. I'm going with your first version; given what I
want to do, I think I'd rather put the code in the pasteboard instead of
the snip.

I've made one further adjustment to your code, and added (super on-event
evt) to the define/override. That way, the pasteboard does what it normally
does, in addition to changing the mouse cursor when it is over the snip.
Without that line, the snip is no longer selectable/draggable/resizable.
(Your second version, where the code is inside the snip, works fine as it
is.)

Thanks again.

-Joseph

#lang racket/gui

(define f (new frame%
               [label "Adjust Cursor Test"]
               [width 250]
               [height 250]))

(define c (new editor-canvas% [parent f]))

(define hand-cursor-pasteboard%
  (class pasteboard%
    (inherit find-snip set-cursor)
    (define hand-snips '())
    (define/public (add-hand-snip s) (set! hand-snips (cons s hand-snips)))
    (define/override (on-event evt)
      (super on-event evt)
      (define snp (find-snip (send evt get-x) (send evt get-y)))
      (set-cursor (if (member snp hand-snips)
                      hand-cursor
                      #f)))
    (super-new)))
(define hand-cursor (make-object cursor% 'hand))

(define pb (new hand-cursor-pasteboard%))
(send c set-editor pb)

(define ufo (make-object image-snip% "ufo.jpg" 'jpeg))
(send pb insert ufo 100 100)
(send pb add-hand-snip ufo)
(send f show #t)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20140713/531cf8c3/attachment.html>

Posted on the users mailing list.