Do scala mouse events work? as?

I am trying to create a link-like label in scala. But no mouse events work for me. How should they work?

class Hyperlink extends Label{ text = "hyperlink" reactions += { case MouseClicked(_,_,_,_,_) => println("mouse clicked")}} 

I put this on some panel and click on the shortcut like a pro minesweeper player ... and nothing is displayed in the console. Why?

+4
scala swing mouseevent
source share
2 answers

You need to listenTo corresponding thing, something like:

 listenTo(this.mouse.clicks) 

Edit: since 2.8.0 The mouse is deprecated, use the mouse instead

+5
source share

It might have been a comment on the previous answer, but because of my representative, I cannot add comments.

this.Mouse is deprecated and this.mouse should be used instead. Also, this can be a good resource: http://www.scala-lang.org/sid/8

+2
source share

All Articles