Bug 113050 - [Widgets] KeyUp dispatched while dragging mouse with SPACE pressed
Summary: [Widgets] KeyUp dispatched while dragging mouse with SPACE pressed
Status: CLOSED WONTFIX
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 3.1.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-SWT-Inbox CLA
QA Contact: Felipe Heidrich CLA
URL:
Whiteboard: stalebug
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2005-10-19 03:59 EDT by Seok-Ho, Yang CLA
Modified: 2020-01-27 14:48 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Seok-Ho, Yang CLA 2005-10-19 03:59:48 EDT
PanningSelectionTool provides panning, it must happen when space bar is pressed,
and mouse is dragged. But panning doesn't work because KEY_UP event occur when
mouse button is pressed. I'm sure that space bar was holding pressed when mouse
button was pressed.
Comment 1 Randy Hudson CLA 2005-10-19 11:24:53 EDT
Which platform? Which release of GEF and Eclipse?
Comment 2 Seok-Ho, Yang CLA 2005-10-19 23:39:15 EDT
(In reply to comment #1)
> Which platform? Which release of GEF and Eclipse?

Windows XP, GEF 3.1.1, Eclipse 3.1.1
Comment 3 Randy Hudson CLA 2005-10-20 09:35:45 EDT
This is working normally for me.
Comment 4 Seok-Ho, Yang CLA 2005-10-21 08:05:33 EDT
I found the reason and fixed it, but I don't know why that is not working for
only me. I'm using Windows XP for Korean. Can be that the cause of this problem?

My english is so poor, but I'll try to explain.

------------ MyPanningSelectionTool.java -----------
import org.eclipse.gef.tools.PanningSelectionTool;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyEvent;

public class MyPanningSelectionToolEntry extends PanningSelectionTool {
    protected boolean acceptSpaceBar(KeyEvent e) {
        return (e.keyCode!=0 && e.character == ' ' && (e.stateMask &
SWT.MODIFIER_MASK) == 0);
    }
    
}
------------ MyPanningSelectionTool.java -----------

I added "e.keyCode!=0" to original code from PanningSelectionTool.

When I try to pan, the following events occured

1. Press Space Bar
    -> KEY_DOWN Event (e.character=' ', e.keyCode=32)
2. Hold Space Bar and Mouse Drag
    -> KEY_UP Event (e.character=' ', e.keyCode=0)
    -> MOUSE_DRAG Event

PanningSelectionTool checks only e.character, so KEY_UP event leads to state
transition to STATE_INITIAL. MyPanningSelectionTool checks both e.character and
e.keyCode, then the panning is working now.

I tested GEF Logic Example, the panning isn't working in the same manner.
I hope I'm not bothering you.
Comment 5 Randy Hudson CLA 2005-10-21 10:27:08 EDT
I assume SWT is sending the KeyUp event or we wouldn't be running the code you 
mention. Moving to SWT for comment.
Comment 6 Steve Northover CLA 2006-04-04 16:55:02 EDT
This seems to be working for me too (tested on English XP).  When the space key is released, the keyCode value should be 32.
Comment 7 Steve Northover CLA 2006-04-04 16:55:41 EDT
Can you make it happen on your machine using this code?

import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;

public class KeyTest {

static String stateMask (int stateMask) {
	String string = "";
	if ((stateMask & SWT.CTRL) != 0) string += " CTRL";
	if ((stateMask & SWT.ALT) != 0) string += " ALT";
	if ((stateMask & SWT.SHIFT) != 0) string += " SHIFT";
	if ((stateMask & SWT.COMMAND) != 0) string += " COMMAND";
	return string;
}

static String character (char character) {
	switch (character) {
		case 0: 		return "'\\0'";
		case SWT.BS:	return "'\\b'";
		case SWT.CR:	return "'\\r'";
		case SWT.DEL:	return "DEL";
		case SWT.ESC:	return "ESC";
		case SWT.LF:	return "'\\n'";
		case SWT.TAB:	return "'\\t'";
	}
	return "'" + character +"'";
}

static String keyCode (int keyCode) {
	switch (keyCode) {
		
		/* Keyboard and Mouse Masks */
		case SWT.ALT: 		return "ALT";
		case SWT.SHIFT: 	return "SHIFT";
		case SWT.CONTROL:	return "CONTROL";
		case SWT.COMMAND:	return "COMMAND";
			
		/* Non-Numeric Keypad Keys */
		case SWT.ARROW_UP:		return "ARROW_UP";
		case SWT.ARROW_DOWN:	return "ARROW_DOWN";
		case SWT.ARROW_LEFT:	return "ARROW_LEFT";
		case SWT.ARROW_RIGHT:	return "ARROW_RIGHT";
		case SWT.PAGE_UP:		return "PAGE_UP";
		case SWT.PAGE_DOWN:		return "PAGE_DOWN";
		case SWT.HOME:			return "HOME";
		case SWT.END:			return "END";
		case SWT.INSERT:		return "INSERT";

		/* Virtual and Ascii Keys */
		case SWT.BS:	return "BS";
		case SWT.CR:	return "CR";		
		case SWT.DEL:	return "DEL";
		case SWT.ESC:	return "ESC";
		case SWT.LF:	return "LF";
		case SWT.TAB:	return "TAB";
	
		/* Functions Keys */
		case SWT.F1:	return "F1";
		case SWT.F2:	return "F2";
		case SWT.F3:	return "F3";
		case SWT.F4:	return "F4";
		case SWT.F5:	return "F5";
		case SWT.F6:	return "F6";
		case SWT.F7:	return "F7";
		case SWT.F8:	return "F8";
		case SWT.F9:	return "F9";
		case SWT.F10:	return "F10";
		case SWT.F11:	return "F11";
		case SWT.F12:	return "F12";
		case SWT.F13:	return "F13";
		case SWT.F14:	return "F14";
		case SWT.F15:	return "F15";
		
		/* Numeric Keypad Keys */
		case SWT.KEYPAD_ADD:		return "KEYPAD_ADD";
		case SWT.KEYPAD_SUBTRACT:	return "KEYPAD_SUBTRACT";
		case SWT.KEYPAD_MULTIPLY:	return "KEYPAD_MULTIPLY";
		case SWT.KEYPAD_DIVIDE:		return "KEYPAD_DIVIDE";
		case SWT.KEYPAD_DECIMAL:	return "KEYPAD_DECIMAL";
		case SWT.KEYPAD_CR:			return "KEYPAD_CR";
		case SWT.KEYPAD_0:			return "KEYPAD_0";
		case SWT.KEYPAD_1:			return "KEYPAD_1";
		case SWT.KEYPAD_2:			return "KEYPAD_2";
		case SWT.KEYPAD_3:			return "KEYPAD_3";
		case SWT.KEYPAD_4:			return "KEYPAD_4";
		case SWT.KEYPAD_5:			return "KEYPAD_5";
		case SWT.KEYPAD_6:			return "KEYPAD_6";
		case SWT.KEYPAD_7:			return "KEYPAD_7";
		case SWT.KEYPAD_8:			return "KEYPAD_8";
		case SWT.KEYPAD_9:			return "KEYPAD_9";
		case SWT.KEYPAD_EQUAL:		return "KEYPAD_EQUAL";

		/* Other keys */
		case SWT.CAPS_LOCK:		return "CAPS_LOCK";
		case SWT.NUM_LOCK:		return "NUM_LOCK";
		case SWT.SCROLL_LOCK:	return "SCROLL_LOCK";
		case SWT.PAUSE:			return "PAUSE";
		case SWT.BREAK:			return "BREAK";
		case SWT.PRINT_SCREEN:	return "PRINT_SCREEN";
		case SWT.HELP:			return "HELP";
	}
	return character ((char) keyCode);
}

public static void main (String [] args) {
	Display display = new Display ();
	Shell shell = new Shell (display);
	Listener listener = new Listener() {
		public void handleEvent(Event e) {
			String string = e.type == SWT.KeyDown ? "DOWN:" : "UP  :";
			string += " stateMask=0x" + Integer.toHexString (e.stateMask) + stateMask (e.stateMask) + ",";
			string += " keyCode=0x" + Integer.toHexString (e.keyCode) + " " + keyCode (e.keyCode) + ",";
			string += " character=0x" + Integer.toHexString (e.character) + " " + character (e.character);
			System.out.println (string);
		}
	};
	shell.addListener(SWT.KeyDown, listener);
	shell.addListener(SWT.KeyUp, listener);
	shell.setSize (200, 200);
	shell.open ();
	while (!shell.isDisposed ()) {
		if (!display.readAndDispatch ()) display.sleep ();
	}
	display.dispose ();
}
}
Comment 8 Seok-Ho, Yang CLA 2006-04-04 23:54:15 EDT
I tested your code.
I wish that this result helps you.

--- Environment ---
MS Windows XP Pro SP2 for Korean
Intel Celeron 2.8G, 1G RAM
JRE: Sun JDK 1.5.0_06

--- Result ---
DOWN: stateMask=0x0, keyCode=0x20 ' ', character=0x20 ' ' <-- Press Spacebar
UP : stateMask=0x0, keyCode=0x20 ' ', character=0x20 ' ' <-- Release Spacebar in a short time
DOWN: stateMask=0x0, keyCode=0x20 ' ', character=0x20 ' ' <-- Start to hold Spacebar
DOWN: stateMask=0x0, keyCode=0x20 ' ', character=0x20 ' ' 
DOWN: stateMask=0x0, keyCode=0x20 ' ', character=0x20 ' '
DOWN: stateMask=0x0, keyCode=0x20 ' ', character=0x20 ' '
DOWN: stateMask=0x0, keyCode=0x20 ' ', character=0x20 ' '
UP : stateMask=0x0, keyCode=0x20 ' ', character=0x20 ' ' <-- Release Spacebar
DOWN: stateMask=0x0, keyCode=0x20 ' ', character=0x20 ' '<-- Start to hold space
DOWN: stateMask=0x0, keyCode=0x20 ' ', character=0x20 ' '
DOWN: stateMask=0x0, keyCode=0x20 ' ', character=0x20 ' '
UP : stateMask=0x0, keyCode=0x0 '\0', character=0x20 ' ' <-- click mouse left-button
DOWN: stateMask=0x80000, keyCode=0x20 ' ', character=0x20 ' '
DOWN: stateMask=0x80000, keyCode=0x20 ' ', character=0x20 ' '
DOWN: stateMask=0x80000, keyCode=0x20 ' ', character=0x20 ' '
DOWN: stateMask=0x80000, keyCode=0x20 ' ', character=0x20 ' ' <-- release button
DOWN: stateMask=0x0, keyCode=0x20 ' ', character=0x20 ' '
DOWN: stateMask=0x0, keyCode=0x20 ' ', character=0x20 ' '
DOWN: stateMask=0x0, keyCode=0x20 ' ', character=0x20 ' '
UP : stateMask=0x0, keyCode=0x20 ' ', character=0x20 ' ' <-- release space
Comment 9 Felipe Heidrich CLA 2009-08-19 14:20:26 EDT
Your bug has been moved to triage, visit http://www.eclipse.org/swt/triage.php for more info.
Comment 10 Leo Ufimtsev CLA 2017-08-03 12:29:57 EDT
This is a one-off bulk update. (The last one in the triage migration).

Moving bugs from swt-triaged@eclipse to platform-swt-inbox@eclipse.org and adding "triaged" keyword as per new triage process:
https://wiki.eclipse.org/SWT/Devel/Triage

See Bug 518478 for details.

Tag for notification/mail filters:
@TriageBulkUpdate
Comment 11 Eclipse Genie CLA 2020-01-27 14:48:57 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.