This page is no longer maintained — Please continue to the home page at www.scala-lang.org

[swing] Mouse events not working

3 replies
qwerky
Joined: 2009-07-03,
User offline. Last seen 42 years 45 weeks ago.

Scala 2.7.4, Java SE 1.6.0-12b04, Debian Lenny

Mouse events not catching in BoxPanel reactions, but resize event works :

class Document(t:(String)=>String, logger:Logged) extends SplitPane with
IntrospectableAttributes {
orientation = Orientation.Vertical
resizeWeight = 0.2

leftComponent = new BoxPanel(Orientation.Vertical) {
reactions += {
case ComponentResized(s) =>
println("Resized")
case MouseEntered(c,p,AWTEvent.MOUSE_MOTION_EVENT_MASK) =>
println("Entered")
case MouseClicked(s,p,AWTEvent.MOUSE_EVENT_MASK,c,false) =>
println("Clicked")
case _ =>
}
}
rightComponent = new BoxPanel(Orientation.Vertical)
}

What wrong ?

imaier
Joined: 2008-07-01,
User offline. Last seen 23 weeks 2 days ago.
Re: [swing] Mouse events not working

1.) you should listenTo(mouse.clicks, mouse.moves). See

https://lampsvn.epfl.ch/trac/scala/browser/scala/trunk/src/swing/scala/s...

2.) if you don't care about modifiers, you should do:

case MouseEntered(c,p,_) => ...

3.) that's a pretty old version you are using. Try trunk or a nightly
first to see whether a bug has been fixed in the meanwhile.

Ingo

On 7/31/09 11:31 AM, qwerky wrote:
> Scala 2.7.4, Java SE 1.6.0-12b04, Debian Lenny
>
> Mouse events not catching in BoxPanel reactions, but resize event works :
>
> class Document(t:(String)=>String, logger:Logged) extends SplitPane with
> IntrospectableAttributes {
> orientation = Orientation.Vertical
> resizeWeight = 0.2
>
> leftComponent = new BoxPanel(Orientation.Vertical) {
> reactions += {
> case ComponentResized(s) =>
> println("Resized")
> case MouseEntered(c,p,AWTEvent.MOUSE_MOTION_EVENT_MASK) =>
> println("Entered")
> case MouseClicked(s,p,AWTEvent.MOUSE_EVENT_MASK,c,false) =>
> println("Clicked")
> case _ =>
> }
> }
> rightComponent = new BoxPanel(Orientation.Vertical)
> }
>
> What wrong ?
>

qwerky
Joined: 2009-07-03,
User offline. Last seen 42 years 45 weeks ago.
Re: [swing] Mouse events not working

Ingo Maier-3 wrote:
>
> 1.) you should listenTo(mouse.clicks, mouse.moves). See
> https://lampsvn.epfl.ch/trac/scala/browser/scala/trunk/src/swing/scala/s...
>
maybe Mouse.clicks, Mouse.moves ? i can't find where mouse.clicks,
mouse.moves, keys located...

imaier
Joined: 2008-07-01,
User offline. Last seen 23 weeks 2 days ago.
Re: [swing] Mouse events not working

This is on trunk. The Mouse object has been deprecated in favor of mouse
there.

Ingo

On 8/1/09 11:07 PM, qwerky wrote:
>
>
> Ingo Maier-3 wrote:
>> 1.) you should listenTo(mouse.clicks, mouse.moves). See
>> https://lampsvn.epfl.ch/trac/scala/browser/scala/trunk/src/swing/scala/s...
>>
> maybe Mouse.clicks, Mouse.moves ? i can't find where mouse.clicks,
> mouse.moves, keys located...
>

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland