Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Stop movement of slider
Stop movement of slider [message #453869] Wed, 13 April 2005 08:26 Go to next message
Rudolf Traunmüller is currently offline Rudolf TraunmüllerFriend
Messages: 21
Registered: July 2009
Junior Member
Is there a way to stop the movement of the slider at a certain
position? I want the user to drag the thumb until it reaches a critial
value, say 70% of the whole distance. Then the user should be able to
move the mouse further but the slider should stop at 70%.
Re: Stop movement of slider [message #453915 is a reply to message #453869] Wed, 13 April 2005 18:20 Go to previous message
Emil Crumhorn is currently offline Emil CrumhornFriend
Messages: 169
Registered: July 2009
Senior Member
I don't think you can do event.doit = false on a SelectionListener for a
slider, but you could do this:

final slider = new Slider(...)...

slider.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {}
public void widgetSelected(SelectionEvent e) {
if (slider.getSelection() >= 70)
slider.setSelection(70);
}
});

So if the user drops the slider > 70, it jumps back to 70.. You still get a
bit of a "boing boing" effect as you can still drag to 100 and let go. But
the drop will still be on 70.

Hope that helps,

Emil

"Rudolf Traunm
Previous Topic:Add Listener for when a checkbox in a tree is checked.
Next Topic:How to propagate event to parent?
Goto Forum:
  


Current Time: Fri Apr 19 07:58:09 GMT 2024

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

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

Back to the top