[racket] how can I get canvas's x and y? when it is scrolled?
how can I get image's x and y?
in short, the scrollbar was moved so I can see image's area whose x
and y are from 90, 90 to 290, 290.
at this moment, I move mouse to upper-left corner of the window. and get 0,0.
but I want to get 90,90.
how can I do this?
thanks!
here my code
#lang racket/gui
(require racket/draw)
(define f
(new frame%
[label "hey"]
[width 200]
[height 200]))
(define img (read-bitmap "some_image.png"))
(define img-w (send img get-width))
(define img-h (send img get-height))
(define (pcb c dc)
(send dc draw-bitmap img 0 0))
(define my_c%
(class canvas%
(define/override (on-event e)
(printf "x: ~a y: ~a \n" (send e get-x) (send e get-y)))
(super-new)))
(define c (new my_c%
[parent f]
[style (list 'hscroll 'vscroll)]
[paint-callback pcb]))
(send c init-auto-scrollbars img-w img-h 0 0)
(send f show #t)