Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » disable selection in List?
disable selection in List? [message #462005] Tue, 04 October 2005 20:24 Go to next message
Walter Harley is currently offline Walter Harley
Messages: 847
Registered: July 2009
Senior Member
How can I disable selection in a List?

I have a org.eclipse.jface.viewers.ListViewer, which displays some strings.
I want my users to be able to scroll horizontally and vertically; but I do
not want them to be able to select items in the list.

I tried simply disabling the List control, but that caused the scrollbars to
be disabled too. I haven't yet tried catching the selection event and
forcing the selection back to null, because I am concerned that may cause
flickering or other odd behaviors on some platforms.

Thanks!
Re: disable selection in List? [message #462046 is a reply to message #462005] Tue, 04 October 2005 22:06 Go to previous messageGo to next message
Steve Northover is currently offline Steve Northover
Messages: 1636
Registered: July 2009
Senior Member
There isn't a way to do this other than to put back the selection after the
user selects it.

"Walter Harley" <wharley@bea.com> wrote in message
news:dhv6fm$t1u$1@news.eclipse.org...
> How can I disable selection in a List?
>
> I have a org.eclipse.jface.viewers.ListViewer, which displays some
strings.
> I want my users to be able to scroll horizontally and vertically; but I do
> not want them to be able to select items in the list.
>
> I tried simply disabling the List control, but that caused the scrollbars
to
> be disabled too. I haven't yet tried catching the selection event and
> forcing the selection back to null, because I am concerned that may cause
> flickering or other odd behaviors on some platforms.
>
> Thanks!
>
>
Code example [message #1021012 is a reply to message #462046] Tue, 19 March 2013 07:10 Go to previous message
Michael Schmid is currently offline Michael Schmid
Messages: 1
Registered: March 2013
Junior Member
Steve Northover wrote
There isn't a way to do this other than to put back the selection after the
user selects it.


Here's a code example for that:
List list = new List (parent, SWT.NONE);
list.add("Element");
list.addSelectionListener(new SelectionListener () {
  @Override
  public void widgetSelected(SelectionEvent e) {
    List l = (List) e.widget;
    l.deselectAll();
  }
  @Override
  public void widgetDefaultSelected(SelectionEvent e) {}
});
Previous Topic:SWT Table Multi Select without strg/shift
Next Topic:Add Controls on Canvas at runtime
Goto Forum:
  


Current Time: Fri Aug 29 04:18:04 EDT 2014

Powered by FUDForum. Page generated in 0.02861 seconds