Canvas Events

Just in case anybody else is (like me) just coming to something like this now in 2019, I was wondering the same as Terry above about creating a Canvas button which “tracks” the mouse like the standard OS X buttons do, i.e.: if you click in the button, but then leave the control and then release the button that does not count as a click, but if you click, leave, re-enter, and then release, that does still count as a click.

This is what I’ve got to so far, and it seems to work:

https://www.dropbox.com/s/ocp9x0guygxvhs4/canvas_button.zip?dl=1

And a slightly different version for when a “toggle” behaviour is required:

https://www.dropbox.com/s/qh5g6u18jhgwx7y/canvas_toggle_button.zip?dl=1

Nice Charles. The only thing I noted to be incorrect against standard windows behaviour (not sure if mac is the same or not) is if the mouse button is press and held down on a native control, when the cursor is moved over the canvas then the roll over plays which isn’t standard (try it with two native buttons). Maybe check if the mouse is already down when you enter the canvas/check for rollover?

Hello Julian,

I must admit I only very quickly checked it on Macintosh OS X, where it is okay. But yesterday I re-discovered my old Parallels install and a bunch of disk images which included Windows 10, and so was able to take another look and you are quite right.

It seems on Windows (on my version, at least) the MouseEnter fires when another control has been clicked, whereas on Macintosh it does not. (Again, I have only very quickly checked this, and I am by no means an expert, but I think this is the issue?)

Anyway, I added a little conditional compile which seems to resolve things. (Although I’m not sure the conditional is really required, as it seemed to work fine on Mac with it included as “plain” code.)

https://www.dropbox.com/s/ocp9x0guygxvhs4/canvas_button.zip?dl=0

https://www.dropbox.com/s/qh5g6u18jhgwx7y/canvas_toggle_button.zip?dl=0

Regards, Charlie

Also can be downloaded from:

https://storage.googleapis.com/charlierobin-1245.appspot.com/downloads/canvas_button.zip

https://storage.googleapis.com/charlierobin-1245.appspot.com/downloads/canvas_toggle_button.zip