JDK-4522626 : User-constructed MouseEvents don't have correct modifiers
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: generic
  • CPU: generic
  • Submitted: 2001-11-03
  • Updated: 2021-07-13
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Relates :  
Relates :  
Description
The code below demonstrates a number of problems with the modifiers field of manually constructed MouseEvents.

import java.awt.*;
import java.awt.event.*;

public class MouseEventConstruction {
    final static int inmods[] = {
        InputEvent.BUTTON1_MASK,
        InputEvent.BUTTON1_MASK | InputEvent.ALT_MASK,
        InputEvent.BUTTON1_MASK | InputEvent.SHIFT_MASK,
        InputEvent.BUTTON1_MASK | InputEvent.META_MASK,
        InputEvent.BUTTON1_MASK | InputEvent.CTRL_MASK,
        InputEvent.BUTTON1_MASK | InputEvent.SHIFT_MASK | InputEvent.ALT_MASK,
        InputEvent.BUTTON1_MASK | InputEvent.BUTTON2_MASK,
        InputEvent.BUTTON2_MASK | InputEvent.ALT_MASK,
        InputEvent.BUTTON2_MASK | InputEvent.SHIFT_MASK,
        InputEvent.BUTTON2_MASK | InputEvent.META_MASK,
        InputEvent.BUTTON2_MASK | InputEvent.CTRL_MASK,
        };
    final static int numEvents = inmods.length;

    public static void main(String[] args) {
        Frame dummy = new Frame("dummy");
        MouseEvent event;
        for(int loop = 0; loop < numEvents; loop++) {
            event = new MouseEvent(dummy,
                                   MouseEvent.MOUSE_PRESSED,
                                   0,
                                   inmods[loop],
                                   0,0,0,false);
            if (event.getModifiers() != inmods[loop]) {
                System.out.println("[" + loop + "]Test failed for mask " + inmods[loop] + ", got: " + event.getModifiers());
            }
        }
        System.out.println("Test done.");
    }
}

Comments
- this is an issue reported against 7(7u), - there are now affected version 9 filed for this issue - 7u issues are transferred to Sustaining Nevertheless if someone have a report against 9 - please reopen and add affectedVersion 9 or 7u specific escalations might be reopen to Sustaining
10-08-2014

- this is an issue reported against 7(7u), - there are now affected version 9 filed for this issue - 7u issues are transferred to Sustaining Nevertheless if someone have a report against 9 - please reopen and add affectedVersion 9 or 7u specific escalations might be reopen to Sustaining
10-08-2014

SUGGESTED FIX ------- MouseEvent.java ------- *** /tmp/sccs.ibaqyh Fri Oct 18 16:48:51 2002 --- MouseEvent.java Fri Oct 18 16:48:40 2002 *************** *** 605,623 **** { if ((modifiers & BUTTON1_MASK) != 0) { button = BUTTON1; - modifiers &= ~BUTTON2_MASK & ~BUTTON3_MASK; if (id != MOUSE_PRESSED) { modifiers &= ~BUTTON1_DOWN_MASK; } } else if ((modifiers & BUTTON2_MASK) != 0) { button = BUTTON2; - modifiers &= ~BUTTON1_MASK & ~BUTTON3_MASK; if (id != MOUSE_PRESSED) { modifiers &= ~BUTTON2_DOWN_MASK; } } else if ((modifiers & BUTTON3_MASK) != 0) { button = BUTTON3; - modifiers &= ~BUTTON1_MASK & ~BUTTON2_MASK; if (id != MOUSE_PRESSED) { modifiers &= ~BUTTON3_DOWN_MASK; } --- 605,620 ----
17-09-2004

EVALUATION Regression - commit to hopper. ###@###.### 2001-11-02 There are also problems with the mapping of modifiers when MouseEvents are delivered to lightweights, because the LightweightDispatcher often creates a new MouseEvent for the retargeted Component, effectively causing the modifiers to be mapped twice. ###@###.### 2001-11-06 Fixing this in mantis would cause a backward-incompatible change versus hopper, so I'd prefer to fix this in tiger. ###@###.### 2002-10-18
06-11-2001