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

Bug 351265

Summary: SWT: Numberkeystrokes support only Keypad
Product: z_Archived Reporter: Nathan Burgherr <nathan.burgherr>
Component: ScoutAssignee: Project Inbox <scout.core-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: Andreas.Hoegger, wayne.beaton, zimmermann
Version: unspecifiedFlags: zimmermann: indigo+
zimmermann: juno+
Target Milestone: ---   
Hardware: PC   
OS: Windows Vista   
Whiteboard:
Attachments:
Description Flags
Patch for projects ui.swt and testing.client
none
Patch for projects ui.swt and testing.client zimmermann: iplog+

Description Nathan Burgherr CLA 2011-07-06 02:34:31 EDT
Build Identifier: 

If you register a keystroke with a number, it listens only to the numbers on the keypad but not to those over the alphabetical keys.

Solution hint:
In the SwtUtility class in getKeyStrokes there is a special Case for the CR. It registers the normal CR and the one on the keypad. The same is needed for the numbers.

public static ISwtKeyStroke[] getKeyStrokes(IKeyStroke stroke, ISwtEnvironment environment) {
    ArrayList<ISwtKeyStroke> swtKeyStrokes = new ArrayList<ISwtKeyStroke>();
    int keycode = getSwtKeyCode(stroke);
    int stateMask = getSwtStateMask(stroke);
    // in case of enter register keypad enter as well
    if (keycode == SWT.CR) {
      swtKeyStrokes.add(new SwtScoutKeyStroke(stroke, SWT.CR, stateMask, environment));
      swtKeyStrokes.add(new SwtScoutKeyStroke(stroke, SWT.KEYPAD_CR, stateMask, environment));
    }
    else {
      swtKeyStrokes.add(new SwtScoutKeyStroke(stroke, keycode, stateMask, environment));
    }
    return swtKeyStrokes.toArray(new ISwtKeyStroke[swtKeyStrokes.size()]);
  }


Reproducible: Always

Steps to Reproduce:
1. Register a number key as keystroke somewhere in the application
    @Order(50.0)
    public class FiveKeyStroke extends AbstractKeyStroke {

      @Override
      protected String getConfiguredKeyStroke() {
        return "5";
      }

      @Override
      protected void execAction() throws ProcessingException {
        System.out.println("5 pressed");
      }
    }
2. Start application an try to get into execAction throug hitting 5 over the alphapetical keys
Comment 1 Claudio Guglielmo CLA 2011-07-15 08:15:22 EDT
Created attachment 199738 [details]
Patch for projects ui.swt and testing.client
Comment 2 Claudio Guglielmo CLA 2011-07-15 08:21:29 EDT
Created attachment 199740 [details]
Patch for projects ui.swt and testing.client
Comment 3 Andreas Hoegger CLA 2011-07-15 17:09:01 EDT
Patch applied for Indigo SP1 and trunk.
Thank you Claudio.
Comment 4 Wayne Beaton CLA 2011-09-20 07:39:52 EDT
The patch, if applied to the code base, must be flagged iplog+ so that it appears in the log.
Comment 5 Matthias Zimmermann CLA 2011-10-10 12:51:40 EDT
shipped with scout 3.7.1
Comment 6 Matthias Zimmermann CLA 2011-10-11 11:44:51 EDT
removed iplog flag from ticket and added iplog flag to attachment