Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 384961

Summary: Selection event in table doesn't reveal if selection is triggered by mouse or keyboard
Product: [RT] RAP Reporter: Moritz Post <mpost>
Component: RWTAssignee: Project Inbox <rap-inbox>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: tbuschto
Version: unspecified   
Target Milestone: 2.3 M3   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Moritz Post CLA 2012-07-12 11:15:36 EDT
The SelectionEvent passed to a selection listener on a table does not have its stateMask correctly set as to reveal if the selection is triggered by mouse or keyboard.
Comment 1 Ivan Furnadjiev CLA 2012-07-12 11:34:02 EDT
Moritz, just checked with Controls Demo -> Table tab and the stateMask is correctly set on the SelectionEvent. Could you explain the problem in more details?
Comment 2 Ivan Furnadjiev CLA 2012-07-13 05:40:59 EDT
Could you provide a simple snippet how the mouse/keyboard is detected from the SelectionEvent#stateMask? By checking the stateMask against mouse buttons modifiers?
Comment 3 Moritz Post CLA 2012-07-16 05:24:43 EDT
Here is a sample snippet:

this.getControl().addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
                final boolean leftButton = (e.stateMask & SWT.BUTTON1) != 0;
                final boolean rightButton = (e.stateMask & SWT.BUTTON3) != 0;
                final boolean mouseSelection = leftButton || rightButton;
                if (mouseSelection) {
                        System.out.println("Mouse selection");
                        PvTTable.this.uebertrageSelektionZurView();
                } else {
                        System.out.println("Key selection - delay transmission");
                        PvTTable.this.handleTimer();
                }
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
                System.out.println(e.detail + " / " + e.stateMask);
                PvTTable.this.uebertrageDefaultAktionZurView();
        }
});
Comment 4 Tim Buschtoens CLA 2012-09-27 08:39:34 EDT
Since the javadoc doesn't mention this feature i will mark this as an enhancement.
Comment 5 Ivan Furnadjiev CLA 2014-04-22 08:00:29 EDT
Fixed in master with change https://git.eclipse.org/r/25184.