Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » List - SelectionEvent
List - SelectionEvent [message #444518] Thu, 14 October 2004 17:09 Go to next message
Scott Pelton is currently offline Scott PeltonFriend
Messages: 81
Registered: July 2009
Member
I have a List widget that allows multi-select. I want to listen to each
SelectionEvent and do a validation. I am not clear as to which field in
the SelectionEvent tells me which "item" in my list was just selected. (in
other words, how do I know which selectable "item" in my List widget
caused this SelectionEvent?)

From the api docs it seems to say the "item" field (which is a Widget) of
the SelectionEvent is the selected "item". But this does not make sense
since all "items" in the List are java.lang.String.
Re: List - SelectionEvent [message #444561 is a reply to message #444518] Thu, 14 October 2004 17:38 Go to previous messageGo to next message
Scott Pelton is currently offline Scott PeltonFriend
Messages: 81
Registered: July 2009
Member
I may have answered my own question - which really turns out to be not
much of an answer at all really. I simply examined what I got back from
SelectionEvent after selecting the first 5 items and the last 5 items in
my List of 26 items (see println() output below).

The method "getFocusIndex()" is a method of List and seems to be the
answer... so in short the SelectionEvent is useless for List...or am I
missing something?

10:35:06 - main : SelectionEvent
10:35:06 - main : e.detail==0
10:35:06 - main : e.item==null
10:35:06 - main : e.x==0
10:35:06 - main : e.y==0
10:35:06 - main : e.height==0
10:35:06 - main : e.width==0
10:35:06 - main : getFocusIndex()==0
10:35:07 - main : SelectionEvent
10:35:07 - main : e.detail==0
10:35:07 - main : e.item==null
10:35:07 - main : e.x==0
10:35:07 - main : e.y==0
10:35:07 - main : e.height==0
10:35:07 - main : e.width==0
10:35:07 - main : getFocusIndex()==1
10:35:08 - main : SelectionEvent
10:35:08 - main : e.detail==0
10:35:08 - main : e.item==null
10:35:08 - main : e.x==0
10:35:08 - main : e.y==0
10:35:08 - main : e.height==0
10:35:08 - main : e.width==0
10:35:08 - main : getFocusIndex()==2
10:35:08 - main : SelectionEvent
10:35:08 - main : e.detail==0
10:35:08 - main : e.item==null
10:35:08 - main : e.x==0
10:35:08 - main : e.y==0
10:35:08 - main : e.height==0
10:35:08 - main : e.width==0
10:35:08 - main : getFocusIndex()==3
10:35:09 - main : SelectionEvent
10:35:09 - main : e.detail==0
10:35:09 - main : e.item==null
10:35:09 - main : e.x==0
10:35:09 - main : e.y==0
10:35:09 - main : e.height==0
10:35:09 - main : e.width==0
10:35:09 - main : getFocusIndex()==4
10:35:11 - main : SelectionEvent
10:35:11 - main : e.detail==0
10:35:11 - main : e.item==null
10:35:11 - main : e.x==0
10:35:11 - main : e.y==0
10:35:11 - main : e.height==0
10:35:11 - main : e.width==0
10:35:11 - main : getFocusIndex()==25
10:35:12 - main : SelectionEvent
10:35:12 - main : e.detail==0
10:35:12 - main : e.item==null
10:35:12 - main : e.x==0
10:35:12 - main : e.y==0
10:35:12 - main : e.height==0
10:35:12 - main : e.width==0
10:35:12 - main : getFocusIndex()==24
10:35:13 - main : SelectionEvent
10:35:13 - main : e.detail==0
10:35:13 - main : e.item==null
10:35:13 - main : e.x==0
10:35:13 - main : e.y==0
10:35:13 - main : e.height==0
10:35:13 - main : e.width==0
10:35:13 - main : getFocusIndex()==23
10:35:13 - main : SelectionEvent
10:35:13 - main : e.detail==0
10:35:13 - main : e.item==null
10:35:13 - main : e.x==0
10:35:13 - main : e.y==0
10:35:13 - main : e.height==0
10:35:13 - main : e.width==0
10:35:13 - main : getFocusIndex()==22
10:35:15 - main : SelectionEvent
10:35:15 - main : e.detail==0
10:35:15 - main : e.item==null
10:35:15 - main : e.x==0
10:35:15 - main : e.y==0
10:35:15 - main : e.height==0
10:35:15 - main : e.width==0
10:35:15 - main : getFocusIndex()==21


Scott Pelton wrote:

> I have a List widget that allows multi-select. I want to listen to each
> SelectionEvent and do a validation. I am not clear as to which field in
> the SelectionEvent tells me which "item" in my list was just selected. (in
> other words, how do I know which selectable "item" in my List widget
> caused this SelectionEvent?)

> From the api docs it seems to say the "item" field (which is a Widget) of
> the SelectionEvent is the selected "item". But this does not make sense
> since all "items" in the List are java.lang.String.
Re: List - SelectionEvent [message #444563 is a reply to message #444561] Thu, 14 October 2004 18:35 Go to previous message
Scott Pelton is currently offline Scott PeltonFriend
Messages: 81
Registered: July 2009
Member
Also, setting doit = false does not prevent the event from selecting the
item.
(NOTE: All this refers to platform: PPC2003.)

Scott Pelton wrote:

> I may have answered my own question - which really turns out to be not
> much of an answer at all really. I simply examined what I got back from
> SelectionEvent after selecting the first 5 items and the last 5 items in
> my List of 26 items (see println() output below).

> The method "getFocusIndex()" is a method of List and seems to be the
> answer... so in short the SelectionEvent is useless for List...or am I
> missing something?

> 10:35:06 - main : SelectionEvent
> 10:35:06 - main : e.detail==0
> 10:35:06 - main : e.item==null
> 10:35:06 - main : e.x==0
> 10:35:06 - main : e.y==0
> 10:35:06 - main : e.height==0
> 10:35:06 - main : e.width==0
> 10:35:06 - main : getFocusIndex()==0
> 10:35:07 - main : SelectionEvent
> 10:35:07 - main : e.detail==0
> 10:35:07 - main : e.item==null
> 10:35:07 - main : e.x==0
> 10:35:07 - main : e.y==0
> 10:35:07 - main : e.height==0
> 10:35:07 - main : e.width==0
> 10:35:07 - main : getFocusIndex()==1
> 10:35:08 - main : SelectionEvent
> 10:35:08 - main : e.detail==0
> 10:35:08 - main : e.item==null
> 10:35:08 - main : e.x==0
> 10:35:08 - main : e.y==0
> 10:35:08 - main : e.height==0
> 10:35:08 - main : e.width==0
> 10:35:08 - main : getFocusIndex()==2
> 10:35:08 - main : SelectionEvent
> 10:35:08 - main : e.detail==0
> 10:35:08 - main : e.item==null
> 10:35:08 - main : e.x==0
> 10:35:08 - main : e.y==0
> 10:35:08 - main : e.height==0
> 10:35:08 - main : e.width==0
> 10:35:08 - main : getFocusIndex()==3
> 10:35:09 - main : SelectionEvent
> 10:35:09 - main : e.detail==0
> 10:35:09 - main : e.item==null
> 10:35:09 - main : e.x==0
> 10:35:09 - main : e.y==0
> 10:35:09 - main : e.height==0
> 10:35:09 - main : e.width==0
> 10:35:09 - main : getFocusIndex()==4
> 10:35:11 - main : SelectionEvent
> 10:35:11 - main : e.detail==0
> 10:35:11 - main : e.item==null
> 10:35:11 - main : e.x==0
> 10:35:11 - main : e.y==0
> 10:35:11 - main : e.height==0
> 10:35:11 - main : e.width==0
> 10:35:11 - main : getFocusIndex()==25
> 10:35:12 - main : SelectionEvent
> 10:35:12 - main : e.detail==0
> 10:35:12 - main : e.item==null
> 10:35:12 - main : e.x==0
> 10:35:12 - main : e.y==0
> 10:35:12 - main : e.height==0
> 10:35:12 - main : e.width==0
> 10:35:12 - main : getFocusIndex()==24
> 10:35:13 - main : SelectionEvent
> 10:35:13 - main : e.detail==0
> 10:35:13 - main : e.item==null
> 10:35:13 - main : e.x==0
> 10:35:13 - main : e.y==0
> 10:35:13 - main : e.height==0
> 10:35:13 - main : e.width==0
> 10:35:13 - main : getFocusIndex()==23
> 10:35:13 - main : SelectionEvent
> 10:35:13 - main : e.detail==0
> 10:35:13 - main : e.item==null
> 10:35:13 - main : e.x==0
> 10:35:13 - main : e.y==0
> 10:35:13 - main : e.height==0
> 10:35:13 - main : e.width==0
> 10:35:13 - main : getFocusIndex()==22
> 10:35:15 - main : SelectionEvent
> 10:35:15 - main : e.detail==0
> 10:35:15 - main : e.item==null
> 10:35:15 - main : e.x==0
> 10:35:15 - main : e.y==0
> 10:35:15 - main : e.height==0
> 10:35:15 - main : e.width==0
> 10:35:15 - main : getFocusIndex()==21


> Scott Pelton wrote:

> > I have a List widget that allows multi-select. I want to listen to each
> > SelectionEvent and do a validation. I am not clear as to which field in
> > the SelectionEvent tells me which "item" in my list was just selected. (in
> > other words, how do I know which selectable "item" in my List widget
> > caused this SelectionEvent?)

> > From the api docs it seems to say the "item" field (which is a Widget) of
> > the SelectionEvent is the selected "item". But this does not make sense
> > since all "items" in the List are java.lang.String.
Previous Topic:Wrapping in Text Widget
Next Topic:Fill Layout and Sash question
Goto Forum:
  


Current Time: Sun Oct 25 05:26:03 GMT 2020

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

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

Back to the top