alexharsanyi
2021-4-19 08:35:16

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…


soegaard2
2021-4-19 08:45:13

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


soegaard2
2021-4-19 08:47:59

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


soegaard2
2021-4-19 08:51:55

Well, the canvas-mixin uses addTrackingRect.

<https://github.com/racket/gui/blob/master/gui-lib/mred/private/wx/cocoa/canvas.rkt#L545>


alexharsanyi
2021-4-19 09:17:09

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


sorawee
2021-4-19 10:45:09

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



sorawee
2021-4-19 10:46:31

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


josh803
2021-4-19 17:03:06

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.



samth
2021-4-19 18:15:54

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


samth
2021-4-19 18:16:20

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


a.nastaev
2021-4-19 18:51:15

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!


soegaard2
2021-4-19 18:51:55

Did you by chance insert images into the source file?


a.nastaev
2021-4-19 18:53:12

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


laurent.orseau
2021-4-19 18:53:42

Make sure you save it as plain text anyway


soegaard2
2021-4-19 18:54:38

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


soegaard2
2021-4-19 18:55:13

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


a.nastaev
2021-4-19 18:55:29

yeah, sure! 1 sec


a.nastaev
2021-4-19 18:56:24

soegaard2
2021-4-19 18:56:27

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


soegaard2
2021-4-19 18:56:51

Ah - the culprit is the comment boxes.


soegaard2
2021-4-19 18:57:06

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


a.nastaev
2021-4-19 18:57:43

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


soegaard2
2021-4-19 18:58:34

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


a.nastaev
2021-4-19 19:02:10

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


sschwarzer
2021-4-19 20:45:46

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