Skip to main content


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] Wed, 05 October 2005 00:24 Go to next message
Walter Harley is currently offline Walter HarleyFriend
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] Wed, 05 October 2005 02:06 Go to previous messageGo to next message
Steve Northover is currently offline Steve NorthoverFriend
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 11:10 Go to previous message
Michael Schmid is currently offline Michael SchmidFriend
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: Wed Apr 24 16:01:14 GMT 2024

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

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

Back to the top