Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » No SelectionEvent when right-clicking Tree
No SelectionEvent when right-clicking Tree [message #462709] Mon, 17 October 2005 17:09 Go to next message
Cameron Bateman is currently offline Cameron BatemanFriend
Messages: 39
Registered: July 2009
Member
I have actions sub-classing BaseSelectionListenerAction attached to the
context-menu for a TreeViewer. They update their selection fine when I
left-mouse click on a TreeItem. However, if I select an item by
right-mouse clicking (and thus open the context menu as part of the same
step), no selection event seems to fire (at least it doesn't reach the
action's selection listener). I have seen similar bugs to this logged in
Bugzilla but all of the ones that are similar are marked fixed pre-dating
Eclipse 3.0.

My platform is Windows XP.

Is there a known issue/work-around for this?


--Cam
Re: No SelectionEvent when right-clicking Tree [message #462736 is a reply to message #462709] Tue, 18 October 2005 15:06 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
Hi Cam,

I've verified that this is working at the SWT level (snippet below) and also
in a simple jface example. I don't know if jface ever chooses to not fire
right-click selection events if there's a context menu to be shown. As an
experiment, see if not having a context menu makes a difference.

In the absence of more definitive follow-ups you should ask this on the
eclipse.platform newsgroup, since that is where the jface component lives.
It may also be helpful if you are able to reduce your code to a small
snippet that demonstrates the problem.

public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setBounds(10,10,400,200);
Tree tree = new Tree(shell, SWT.NONE);
tree.setBounds(10,10,300,100);
new TreeItem(tree, SWT.NONE).setText("item 0");
new TreeItem(tree, SWT.NONE).setText("item 1");
new TreeItem(tree, SWT.NONE).setText("item 2");
Menu menu = new Menu(shell, SWT.POP_UP);
new MenuItem(menu, SWT.NONE).setText("menu item 0");
tree.setMenu(menu);
tree.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
System.out.println("selected: " + event.item);
}
});
shell.open();
while(!shell.isDisposed()) {
if(!display.readAndDispatch()) display.sleep();
}
display.dispose();
}

Grant

"Cameron Bateman" <cbateman@rim.com> wrote in message
news:c96f9f8bb46802aed4afdef24fbd4e04$1@www.eclipse.org...
> I have actions sub-classing BaseSelectionListenerAction attached to the
> context-menu for a TreeViewer. They update their selection fine when I
> left-mouse click on a TreeItem. However, if I select an item by
> right-mouse clicking (and thus open the context menu as part of the same
> step), no selection event seems to fire (at least it doesn't reach the
> action's selection listener). I have seen similar bugs to this logged in
> Bugzilla but all of the ones that are similar are marked fixed pre-dating
> Eclipse 3.0.
>
> My platform is Windows XP.
>
> Is there a known issue/work-around for this?
>
>
> --Cam
>
>
Re: No SelectionEvent when right-clicking Tree [message #462748 is a reply to message #462736] Tue, 18 October 2005 19:19 Go to previous messageGo to next message
Cameron Bateman is currently offline Cameron BatemanFriend
Messages: 39
Registered: July 2009
Member
> I've verified that this is working at the SWT level (snippet below) and also
> in a simple jface example. I don't know if jface ever chooses to not fire
> right-click selection events if there's a context menu to be shown. As an
> experiment, see if not having a context menu makes a difference.

Hi Grant. Thanks for your reply.

In fact, the problem I'm having *is* manifesting in your example, it's
just I didn't describe it specifically enough. To reproduce try this:

1) Select any tree item with the left mouse -- selection event fires.
2) Now click the *same, selected* item again with your right mouse button
-- selection event *does not fire*. However,
3) If you click this already selected item again with the left mouse the
selection event does fire, so unless I'm misunderstanding the semantics of
the event there is inconsistent behaviour between a left and right mouse
event on an *already selected* tree item -- at least on Windows.


--Cam
Re: No SelectionEvent when right-clicking Tree [message #462793 is a reply to message #462748] Wed, 19 October 2005 14:45 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
ok, I see. This is the behaviour across the platforms. Though I don't know
the history behind this definition of Selection, it seems to be by design,
so I don't think that this is a bug. Listening for SWT.MouseDown in
addition to SWT.Selection should allow you to handle left- and right-clicks
the same for selected items.

Grant

"Cameron Bateman" <cbateman@rim.com> wrote in message
news:d72685986299e003b95a884bcf6ee726$1@www.eclipse.org...
> > I've verified that this is working at the SWT level (snippet below) and
also
> > in a simple jface example. I don't know if jface ever chooses to not
fire
> > right-click selection events if there's a context menu to be shown. As
an
> > experiment, see if not having a context menu makes a difference.
>
> Hi Grant. Thanks for your reply.
>
> In fact, the problem I'm having *is* manifesting in your example, it's
> just I didn't describe it specifically enough. To reproduce try this:
>
> 1) Select any tree item with the left mouse -- selection event fires.
> 2) Now click the *same, selected* item again with your right mouse button
> -- selection event *does not fire*. However,
> 3) If you click this already selected item again with the left mouse the
> selection event does fire, so unless I'm misunderstanding the semantics of
> the event there is inconsistent behaviour between a left and right mouse
> event on an *already selected* tree item -- at least on Windows.
>
>
> --Cam
>
Re: No SelectionEvent when right-clicking Tree [message #462795 is a reply to message #462793] Wed, 19 October 2005 14:51 Go to previous messageGo to next message
Cameron Bateman is currently offline Cameron BatemanFriend
Messages: 39
Registered: July 2009
Member
Thanks for the workaround. It is a bit strange that it behaves this way
by design... is there some kind of design doc somewhere that outlines
these sort of things? So far I haven't seen anything in the Help that
comes with Eclipse.

Thanks,

Cameron

Grant Gayed wrote:

> so I don't think that this is a bug. Listening for SWT.MouseDown in
> addition to SWT.Selection should allow you to handle left- and right-clicks
> the same for selected items.
Re: No SelectionEvent when right-clicking Tree [message #462796 is a reply to message #462795] Wed, 19 October 2005 14:55 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
No, there isn't a formal document that gives the history of behaviours such
as this.

"Cameron Bateman" <cbateman@rim.com> wrote in message
news:a1ae0581b0028413b330d3859d8e0a15$1@www.eclipse.org...
> Thanks for the workaround. It is a bit strange that it behaves this way
> by design... is there some kind of design doc somewhere that outlines
> these sort of things? So far I haven't seen anything in the Help that
> comes with Eclipse.
>
> Thanks,
>
> Cameron
>
> Grant Gayed wrote:
>
> > so I don't think that this is a bug. Listening for SWT.MouseDown in
> > addition to SWT.Selection should allow you to handle left- and
right-clicks
> > the same for selected items.
>
>
Re: No SelectionEvent when right-clicking Tree [message #462800 is a reply to message #462748] Wed, 19 October 2005 15:21 Go to previous message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

The only thing I can think of is on some systems right click DOES NOT do
selection. Right click means bring up popup menu only, not select and
bring up popup menu.

Cameron Bateman wrote:
>> I've verified that this is working at the SWT level (snippet below)
>> and also
>> in a simple jface example. I don't know if jface ever chooses to not
>> fire
>> right-click selection events if there's a context menu to be shown.
>> As an
>> experiment, see if not having a context menu makes a difference.
>
>
> Hi Grant. Thanks for your reply.
>
> In fact, the problem I'm having *is* manifesting in your example, it's
> just I didn't describe it specifically enough. To reproduce try this:
>
> 1) Select any tree item with the left mouse -- selection event fires.
> 2) Now click the *same, selected* item again with your right mouse
> button -- selection event *does not fire*. However,
> 3) If you click this already selected item again with the left mouse the
> selection event does fire, so unless I'm misunderstanding the semantics
> of the event there is inconsistent behaviour between a left and right
> mouse event on an *already selected* tree item -- at least on Windows.
>
>
> --Cam
>

--
Thanks,
Rich Kulp
Previous Topic:SWT Browser, silent mode?
Next Topic:Question regarding TreeViewer
Goto Forum:
  


Current Time: Thu Apr 18 19:42:53 GMT 2024

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

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

Back to the top