
I did a bit of research in mouse event handling for OSX — it seems that mouse entered/mouse leave events are only sent to a control if it explicitly requests it, and this is what needs to be used for tool-tips: https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/EventOverview/TrackingAreaObjects/TrackingAreaObjects.html#//apple_ref/doc/uid/10000060i-CH8-SW1\|https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/EventOverview/TrackingAreaObjects/TrackingAreaObjects.html#//app[…]H8-SW1
However, the documentation also mentions that the mouse moved events are also only sent if the control explicitly requests it, yet these are received by the application…
I suppose the tooltip-mixin
could use get-client-handle
and create and register a NSTrackingArea
for the control…

I was looking at the implementation of button%
yesterday. One piece of the puzzle is [1]: (define-objc-mixin (KeyMouseResponder Superclass) ...)
which has this clause: [-a _void (mouseExited: [_id event])
(unless (do-mouse-event wxb event 'leave 'check 'check 'check)
(super-tell #:type _void mouseExited: event))]
It is used to here [2]: (define-objc-class RacketButton NSButton
#:mixins (FocusResponder KeyMouseResponder CursorDisplayer)
[wxb]
(-a _void (clicked: [_id sender])
(queue-window*-event wxb (lambda (wx) (send wx clicked)))))
That is, the lower level ought to report the leave events (at least I think it should).
[1] https://github.com/racket/gui/blob/master/gui-lib/mred/private/wx/cocoa/window.rkt#L140 [2] https://github.com/racket/gui/blob/master/gui-lib/mred/private/wx/cocoa/button.rkt#L29

I can’t find NSTrackingArea
anywhere in the code though.

Well, the canvas-mixin
uses addTrackingRect
.
<https://github.com/racket/gui/blob/master/gui-lib/mred/private/wx/cocoa/canvas.rkt#L545>

yes, the addTrackingRect
is the older way of doing this — see the “Compatibility Issues” section on that page.

You should take a look at quad. It supports ttf without requiring it to be installed


Quad might not be what you eventually want to use, but it’s the starting point that you can take a look.

Hi! Thanks very much for the suggestion, @sorawee! I had looked briefly at it before (and more closely just now), and while it does manipulate fonts it doesn’t use Pango (the engine used by Racket/Draw), so I don’t know how they could be hooked together for what I want to do.

A StackOverflow question for @capfredfand @samth: https://stackoverflow.com/questions/67163023/is-it-possible-to-make-typed-racket-infer-types-through-mapping-functions-and-la

I answered, although the question isn’t really a question.

It’s really “I have analyzed Typed Racket quite thoroughly, but I wish it were different”

I am sure this question was covered before, but still… How can I commit .rkt
file to Github having a proper format as I see it in DrRacket? I mean after the commit my file is basically unreadable. Am I missing something simple here? Thanks a lot in advance!

Did you by chance insert images into the source file?

@soegaard2 no, not at all! I am just doing exercise 235–236 from HTDP2 and there are no images involved…

Make sure you save it as plain text anyway

I ask, because at the moment an image is inserted, DrRacket switches the save mode.

Can you paste a screen shot here of the DrRacket window - maybe we can spot the problem?

yeah, sure! 1 sec


Also, what does the file at github begin with? (It ought to me a recognizable string - maybe wxme)

Ah - the culprit is the comment boxes.

They are so-called “snips” and that triggeres a special save mode.

Aaa, I thought about that… Do I need to comment out my code with semicolons I guess?

Yes. Or use #;(define ...)
to comment out an s-expression.

@soegaard2 thanks a lot! I really appreciate it! All works as it should be! Thanks a lot again!

@a.nastaev You can also wrap (even multi-line) comments in #\|
and \|#
. And you can even nest such comments.