1070 wnd.selectItem(null, false);
1071 }
1072 }
1073 }
1074 break;
1075 case MouseEvent.MOUSE_RELEASED:
1076 //Note that if item is not null, wnd has to be not null
1077 if (item != null && !item.isSeparator() && item.isTargetItemEnabled()) {
1078 if (item instanceof XMenuPeer) {
1079 if (showingMousePressedSubmenu == item) {
1080 //User clicks on item that shows submenu.
1081 //Hide the submenu
1082 if (wnd instanceof XMenuBarPeer) {
1083 ungrabInput();
1084 } else {
1085 wnd.selectItem(item, false);
1086 }
1087 }
1088 } else {
1089 //Invoke action event
1090 item.action(mouseEvent.getWhen(), mouseEvent.getModifiers());
1091 ungrabInput();
1092 }
1093 } else {
1094 //Mouse is released outside menu items
1095 if (hasPointerMoved || (wnd instanceof XMenuBarPeer)) {
1096 ungrabInput();
1097 }
1098 }
1099 showingMousePressedSubmenu = null;
1100 break;
1101 case MouseEvent.MOUSE_DRAGGED:
1102 if (wnd != null) {
1103 //Mouse is dragged over menu window
1104 //Move selection to item under cursor
1105 if (item != null && !item.isSeparator() && item.isTargetItemEnabled()) {
1106 if (grabWindow == this){
1107 wnd.selectItem(item, true);
1108 }
1109 } else {
1110 wnd.selectItem(null, false);
1183 //select next item
1184 selectItem(getNextSelectableItem(), false);
1185 } else if (citem instanceof XMenuPeer) {
1186 //current item is menu, show its window
1187 //(equivalent of ENTER)
1188 cwnd.selectItem(citem, true);
1189 } else if (this instanceof XMenuBarPeer) {
1190 //if this is menu bar (not popup menu)
1191 //and the user presses RIGHT on item (not submenu)
1192 //select next top-level menu
1193 selectItem(getNextSelectableItem(), true);
1194 }
1195 break;
1196 case KeyEvent.VK_SPACE:
1197 case KeyEvent.VK_ENTER:
1198 //If the current item has submenu show it
1199 //Perform action otherwise
1200 if (citem instanceof XMenuPeer) {
1201 cwnd.selectItem(citem, true);
1202 } else if (citem != null) {
1203 citem.action(event.getWhen(), event.getModifiers());
1204 ungrabInput();
1205 }
1206 break;
1207 case KeyEvent.VK_ESCAPE:
1208 //If current window is menu bar or its child - close it
1209 //If current window is popup menu - close it
1210 //go one level up otherwise
1211
1212 //Fixed 6266513: Incorrect key handling in XAWT popup menu
1213 //Popup menu should be closed on 'ESC'
1214 if ((cwnd instanceof XMenuBarPeer) || (cwnd.getParentMenuWindow() instanceof XMenuBarPeer)) {
1215 ungrabInput();
1216 } else if (cwnd instanceof XPopupMenuPeer) {
1217 ungrabInput();
1218 } else {
1219 XBaseMenuWindow pwnd = cwnd.getParentMenuWindow();
1220 pwnd.selectItem(pwnd.getSelectedItem(), false);
1221 }
1222 break;
1223 case KeyEvent.VK_F10:
|
1070 wnd.selectItem(null, false);
1071 }
1072 }
1073 }
1074 break;
1075 case MouseEvent.MOUSE_RELEASED:
1076 //Note that if item is not null, wnd has to be not null
1077 if (item != null && !item.isSeparator() && item.isTargetItemEnabled()) {
1078 if (item instanceof XMenuPeer) {
1079 if (showingMousePressedSubmenu == item) {
1080 //User clicks on item that shows submenu.
1081 //Hide the submenu
1082 if (wnd instanceof XMenuBarPeer) {
1083 ungrabInput();
1084 } else {
1085 wnd.selectItem(item, false);
1086 }
1087 }
1088 } else {
1089 //Invoke action event
1090 @SuppressWarnings("deprecation")
1091 final int modifiers = mouseEvent.getModifiers();
1092 item.action(mouseEvent.getWhen(), modifiers);
1093 ungrabInput();
1094 }
1095 } else {
1096 //Mouse is released outside menu items
1097 if (hasPointerMoved || (wnd instanceof XMenuBarPeer)) {
1098 ungrabInput();
1099 }
1100 }
1101 showingMousePressedSubmenu = null;
1102 break;
1103 case MouseEvent.MOUSE_DRAGGED:
1104 if (wnd != null) {
1105 //Mouse is dragged over menu window
1106 //Move selection to item under cursor
1107 if (item != null && !item.isSeparator() && item.isTargetItemEnabled()) {
1108 if (grabWindow == this){
1109 wnd.selectItem(item, true);
1110 }
1111 } else {
1112 wnd.selectItem(null, false);
1185 //select next item
1186 selectItem(getNextSelectableItem(), false);
1187 } else if (citem instanceof XMenuPeer) {
1188 //current item is menu, show its window
1189 //(equivalent of ENTER)
1190 cwnd.selectItem(citem, true);
1191 } else if (this instanceof XMenuBarPeer) {
1192 //if this is menu bar (not popup menu)
1193 //and the user presses RIGHT on item (not submenu)
1194 //select next top-level menu
1195 selectItem(getNextSelectableItem(), true);
1196 }
1197 break;
1198 case KeyEvent.VK_SPACE:
1199 case KeyEvent.VK_ENTER:
1200 //If the current item has submenu show it
1201 //Perform action otherwise
1202 if (citem instanceof XMenuPeer) {
1203 cwnd.selectItem(citem, true);
1204 } else if (citem != null) {
1205 @SuppressWarnings("deprecation")
1206 final int modifiers = event.getModifiers();
1207 citem.action(event.getWhen(), modifiers);
1208 ungrabInput();
1209 }
1210 break;
1211 case KeyEvent.VK_ESCAPE:
1212 //If current window is menu bar or its child - close it
1213 //If current window is popup menu - close it
1214 //go one level up otherwise
1215
1216 //Fixed 6266513: Incorrect key handling in XAWT popup menu
1217 //Popup menu should be closed on 'ESC'
1218 if ((cwnd instanceof XMenuBarPeer) || (cwnd.getParentMenuWindow() instanceof XMenuBarPeer)) {
1219 ungrabInput();
1220 } else if (cwnd instanceof XPopupMenuPeer) {
1221 ungrabInput();
1222 } else {
1223 XBaseMenuWindow pwnd = cwnd.getParentMenuWindow();
1224 pwnd.selectItem(pwnd.getSelectedItem(), false);
1225 }
1226 break;
1227 case KeyEvent.VK_F10:
|