Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » MouseWheel Events
MouseWheel Events [message #456648] Mon, 06 June 2005 14:27 Go to next message
Omry Yadan is currently offline Omry YadanFriend
Messages: 45
Registered: July 2009
Member
how can I canvas listen to mouse wheel events?
Re: MouseWheel Events [message #456693 is a reply to message #456648] Tue, 07 June 2005 07:04 Go to previous message
Omry Yadan is currently offline Omry YadanFriend
Messages: 45
Registered: July 2009
Member
Omry Yadan wrote:
> how can I canvas listen to mouse wheel events?

Figured it out.
addListener(SWT.MouseWheel, new Listener()
{
public void handleEvent(Event event)
{
int c = event.count;
c = (int) Math.ceil(c / 3.0f);
while (c < 0)
{
scrollDown();
c++;
}

while (c > 0)
{
scrollUp();
c--;
}

}
});


This works only if the Canvas has keyboard focus, so this is also needed:

addMouseTrackListener(new MouseTrackAdapter()
{

public void mouseEnter(MouseEvent e)
{
forceFocus();
}
});
Previous Topic:GC Translate?
Next Topic:Problem with SWT application under Mac OS X
Goto Forum:
  


Current Time: Thu Apr 25 11:03:30 GMT 2024

Powered by FUDForum. Page generated in 0.03091 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top