are scala's mouse events working? how?

蹲街弑〆低调 提交于 2019-12-23 15:28:36

问题


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?


回答1:


You need to listenTo the relevant thing, something like:

listenTo(this.mouse.clicks)

Edit: since 2.8.0 Mouse is deprecated, use mouse instead




回答2:


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



来源:https://stackoverflow.com/questions/2511308/are-scalas-mouse-events-working-how

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!