[racket-dev] get-x method on key event always returns zero?
It appears to me that the 'get-x' method on a key event always returns zero, counter to what the docs say. Is this a doc bug, a software bug, or just me being dumb?
FWIW, here's a simple program that illustrates this; press a key while the window has focus, and you will always see 0 in the x value field:
#lang racket/base
(require racket/gui
racket/class)
(define sound-canvas%
(class canvas%
(init-field frame-num-text)
(init-field y-value-text)
(define/override (on-char evt)
(send y-value-text begin-edit-sequence #f)
(send y-value-text erase)
(send y-value-text insert
(format "x value: ~v"
(send evt get-x)))
(send y-value-text end-edit-sequence)
(send frame-num-text begin-edit-sequence #f)
(send frame-num-text erase)
(send frame-num-text insert (format "key : ~a" (send evt get-key-code)))
(send frame-num-text end-edit-sequence))
(super-new)))
(let* ([f (new frame% [label "abc"] [width 400] [height 100])]
[tx (new text%)]
[ty (new text%)]
[c (new sound-canvas%
[parent f]
#;[paint-callback
(make-sound-drawing-callback left-getter right-getter
len data-left data-right)]
[frame-num-text tx]
[y-value-text ty])]
[ecx (new editor-canvas%
[parent f]
[editor tx]
[style '(no-border no-hscroll no-vscroll)]
[stretchable-width #t]
[stretchable-height #f]
[horizontal-inset 1]
[vertical-inset 1]
[min-width 50]
[min-height 20])]
[ecy (new editor-canvas%
[parent f]
[editor ty]
[style '(no-border no-hscroll no-vscroll)]
[stretchable-width #t]
[stretchable-height #f]
[horizontal-inset 1]
[vertical-inset 1]
[min-width 50]
[min-height 20])])
(send f show #t))