Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » mouse wheel sends extra scroll event(I don't want extra scroll events for mouse wheel)
mouse wheel sends extra scroll event [message #640156] Fri, 19 November 2010 11:34 Go to next message
Thomas M. is currently offline Thomas M.Friend
Messages: 4
Registered: November 2010
Junior Member
Hi

I derived a class from Composite which handles scroll events and mouse wheel events.

My mouse wheel listener already takes care of the necessary scrolling so I don't want the extra scroll events.

These seem to be sent when the CANVAS bit is set for the window. Here's the Scrollable code for Windows (GTK looks similar in structure)


/*
* Translate WM_MOUSEWHEEL to WM_VSCROLL or WM_HSCROLL.
*/
if (update) {

and update is set to (state & CANVAS) != 0

Questions

- How can I prevent scroll events?
- Derive from some different class?
- Can I influence the state (remove the CANVAS bit? or would that have other consequences?)

And lastly. Why does this extra scroll handling set the thumb position to 0???

OS.SendMessage (handle, msg, OS.SB_THUMBPOSITION, 0);

As this always sets the document to the beginning when using the mouse wheel.

Any help appreciated. Thank you in advance.



Re: mouse wheel sends extra scroll event [message #640537 is a reply to message #640156] Mon, 22 November 2010 12:59 Go to previous messageGo to next message
Lakshmi P ShanmugamFriend
Messages: 279
Registered: July 2009
Location: India
Senior Member
Hi,

In your mouse wheel listener you can set the event.doit field of the incoming mouse wheel event to false. This will prevent the default processing of the scroll event.


Lakshmi P Shanmugam
Re: mouse wheel sends extra scroll event [message #640552 is a reply to message #640537] Mon, 22 November 2010 13:30 Go to previous messageGo to next message
Thomas M. is currently offline Thomas M.Friend
Messages: 4
Registered: November 2010
Junior Member
Thanks for your answer. I am afraid I can't get my hand on the doit field as the Event is translated into a MouseEvent which does not have this field.

Also it will not be evaluated. The mouseScrolled handler has void as return type and the passed event is also not evaluated upon return:

case SWT.MouseWheel: 
{
  ((MouseWheelListener) eventListener).mouseScrolled(new MouseEvent(e));
    return;
}
Re: mouse wheel sends extra scroll event [message #640565 is a reply to message #640552] Mon, 22 November 2010 14:04 Go to previous messageGo to next message
Lakshmi P ShanmugamFriend
Messages: 279
Registered: July 2009
Location: India
Senior Member
You should use Widget.addListener (int eventType, Listener listener) to add the listener to your composite. You can have a look at the constructor of the custom classes in org.eclipse.swt.custom to see how the listeners are added.


Lakshmi P Shanmugam

[Updated on: Mon, 22 November 2010 14:05]

Report message to a moderator

Re: mouse wheel sends extra scroll event [message #640596 is a reply to message #640565] Mon, 22 November 2010 15:18 Go to previous message
Thomas M. is currently offline Thomas M.Friend
Messages: 4
Registered: November 2010
Junior Member
Thanks a lot. This does the trick. I was not really aware of these more generic event handlers.
Previous Topic:How to get a reference to a Browser
Next Topic:[solved] drawing to a GC through SWT and native code
Goto Forum:
  


Current Time: Thu Apr 25 22:54:05 GMT 2024

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

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

Back to the top