views:

113

answers:

2

Hi, I'm trying to create link-like label in scala. But no mouse events works for me. How are they supposed to work?

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

I put this in some panel and click over the label like a pro minesweeper player... and nothing shows up in console. Why?

+3  A: 

You need to listenTo the relevant thing, something like:

listenTo(this.Mouse.clicks)
oxbow_lakes
pretty hard to find this in the Api. There should be some reference from classes that extend Component, I think
coubeatczech
+1  A: 

Maybe this should have been a comment to the previous answer, but due to my rep, i cant add comments.

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

terv