即使在Table
上也试图捕捉鼠标点击(这会导致弹出窗口显示)。该表位于ScrollPane
内,Panel
位于class MyPanel extends GridBagPanel {
val gbc = new GridBagContraints( ... )
add(new ScrollPane {
reactions += {
case MouseClicked(src, point, mod, clicks, pops) =>
println("Scroll pops: " + pops)
}
viewportView = new Table {
reactions += {
case MouseClicked(src, point, mod, clicks, pops) =>
println("Table pops: " + pops)
}
...
}
}, gbc)
reactions += {
case MouseClicked(src, point, mod, clicks, pops) =>
println("Panel pops: " + pops)
}
}
内。我已经添加了对所有类的反应,但我似乎永远不会真正得到一个点击事件被捕获!
{{1}}
无论我点击哪里,都不会打印任何内容。我做错了什么?
答案 0 :(得分:5)
好的 - 您必须倾听以正确的事情:
class MyPanel extends GridBagPanel {
val gbc = new GridBagContraints( ... )
val table = new Table { ... }
add(new ScrollPane {
viewportView = table
}
}, gbc)
listenTo(table.Mouse.clicks) //THIS LINE IS IMPORTANT :-)
reactions += {
case MouseClicked(`table`, point, mod, clicks, pops) =>
println("Panel pops: " + pops)
}
}
}