Scala Swing event framework - where do I add my reactors?

前端 未结 1 1964
旧时难觅i
旧时难觅i 2021-01-03 00:56

I\'m trying to catch a mouse-click even on a Table (which should cause a popup to be shown). The table is inside a ScrollPane which is (in turn) in

相关标签:
1条回答
  • 2021-01-03 01:13

    OK - You have to listen to the correct thing:

    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)
        } 
      }
    }
    
    0 讨论(0)
提交回复
热议问题