2010-06-05 Clojure Mouse Listener
Ok, so I got a bit further compared to last time. As you can see I got rid of that fancy macro and decided to just write simple code that works for this particular situation. And it works. 😄
My problem right now is that the mouseClicked code is never called. I wonder why. ¹ ²
It turns out that I needed to call addMouseListener at some place. So app changed:
If I don’t implement all of the MouseListener interface, I end up getting a ton of exceptions whenever the mouse entered or exited the frame and whenever the button was pressed or released. It felt weird adding all those empty methods.
I think I should start thinking about getting a working SlimeMode. 😄
#Clojure
Comments
(Please contact me if you want to remove your comment.)
⁂
Hi, extending MouseListener from the JFrame is not sufficient. This provides a “host” class for your implementation of the listener code, but you still have to register the MouseListener to the JFrame ! In your case, you’ll add the JFrame itself as a MouseListener of itself, something like (not tested) (.addMouseListener jframe jframe)
– Laurent Petit 2010-06-05 11:13 UTC
---
Thanks! I got some help on the #clojure channel and rewrote the code. Will update the page! 😄
I think your code would have worked, but somehow making the JFrame a MouseListener is way too weird. I was confused.
And you’re working on a Clojure Eclipse plugin! Awesome. At work I’ve been using Eclipse a lot, lately. 😄
– Alex Schroeder 2010-06-05 11:36 UTC