- Timestamp:
- 10/31/18 10:20:25 (6 years ago)
- Location:
- trunk/src/org/expeditee/gio/swing
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/expeditee/gio/swing/MouseEventRouter.java
r1180 r1187 33 33 import java.util.List; 34 34 35 import javax.swing.JComboBox; 35 36 import javax.swing.JComponent; 36 37 import javax.swing.JMenuBar; 37 import javax.swing.JPopupMenu;38 38 import javax.swing.SwingUtilities; 39 39 … … 280 280 if (g.getContentPane() != null) { 281 281 if (!g.getContentPane().isFocusOwner() && !isPopupVisible()) { 282 //g.getContentPane().requestFocus();282 g.getContentPane().requestFocus(); 283 283 } 284 284 } … … 381 381 // for (Component c : parent.getComponents()) { 382 382 // if (c instanceof JPopupMenu && ((JPopupMenu) c).isVisible()) { 383 // System.err.println("Popup visible"); 383 384 // return true; 384 385 // … … 386 387 // && c != SwingMiscManager.getIfUsingSwingGraphicsManager().getContentPane()) { 387 388 // if (isPopupVisible((Container) c)) { 389 // System.err.println("Popup visible"); 388 390 // return true; 389 391 // } 390 392 // } 391 393 // } 392 // 394 // System.err.println("Popup not visible"); 393 395 // return false; 394 396 // } 395 397 396 398 private static boolean isPopupVisible(final JComponent parent) { 397 final JPopupMenu popup = parent.getComponentPopupMenu(); 398 if(popup != null) { 399 System.err.println("Here"); 400 } 401 if(popup != null && popup.isVisible()) { 402 return true; 403 } else { 404 for (final Component c : parent.getComponents()) { 405 if(c instanceof JComponent && isPopupVisible((JComponent) c)) { 406 return true; 407 } 399 if(parent instanceof JComboBox) { 400 if(((JComboBox<?>) parent).isPopupVisible()) { return true; } 401 } 402 for (final Component c : parent.getComponents()) { 403 if(c instanceof JComponent && isPopupVisible((JComponent) c)) { 404 //System.err.println("MouseEventRouter::found visible popup"); 405 return true; 408 406 } 409 407 } 410 408 return false; 411 409 } 410 411 // private static boolean isPopupVisible(final JComponent parent) { 412 // final JPopupMenu popup = parent.getComponentPopupMenu(); 413 // if(popup != null) { 414 // System.err.println("Found control with popup"); 415 // } 416 // if(popup != null && popup.isVisible()) { 417 // System.err.println("Popup visible"); 418 // return true; 419 // } else { 420 // for (final Component c : parent.getComponents()) { 421 // if(c instanceof JComponent && isPopupVisible((JComponent) c)) { 422 // System.err.println("Popup visible"); 423 // return true; 424 // } 425 // } 426 // } 427 // System.err.println("Popup not visible"); 428 // return false; 429 // } 412 430 413 431 private MouseEvent duplicateMouseEvent(MouseEvent e, int modifiers) { -
trunk/src/org/expeditee/gio/swing/SwingInputManager.java
r1169 r1187 21 21 import java.awt.event.WindowListener; 22 22 import java.awt.event.WindowStateListener; 23 import java.util.List; 23 24 24 25 import javax.swing.SwingUtilities; … … 348 349 @Override 349 350 public void keyTyped(KeyEvent e) { 351 //System.err.println("SwingInputManager::keyTyped::KeyEvent: " + e.getKeyChar()); 350 352 // Give widgets first whack at input 351 353 distributeNativeInput(e); 352 354 if (e.isConsumed()) { 355 //System.err.println("SwingInputManager::keyTyped::Widget/Popup Consumed KeyEvent"); 353 356 return; 354 357 } … … 383 386 /** Handles key pressed/released events. */ 384 387 private void keyAction(KeyEvent e, boolean down) { 388 //System.err.println("SwingInputManager::keyAction::KeyEvent: " + e.getKeyChar()); 385 389 // Give widgets first whack at input 386 390 distributeNativeInput(e); 387 391 if (e.isConsumed()) { 388 return; 389 } 392 //System.err.println("SwingInputManager::keyAction::Was consumed: " + e.isConsumed()); 393 return; 394 } 395 //System.err.println("SwingInputManager::keyAction::Was consumed: " + e.isConsumed()); 390 396 391 397 KBMInputEvent.Key key = SwingConversions.fromSwingVirtualKey(e.getKeyCode()); … … 418 424 /** Forwards the given input event to the listener if it is listening for it. */ 419 425 private void forwardNativeInputToListener(Object listener, java.awt.event.InputEvent event) { 426 //System.err.println("SwingInputManager::forwardNativeInputToListener"); 420 427 if (listener == null || event == null) { 421 428 return; 422 429 } 423 430 //System.err.println("SwingInputManager::forwardNativeInputToListener::Recieving input: " + event.toString()); 424 431 if (listener instanceof KeyListener && event instanceof KeyEvent) { 425 432 … … 435 442 return; 436 443 case KeyEvent.KEY_TYPED: 444 //System.err.println("SwingInputManager::forwardNativeInputToListener::Recieving key typed: " + event.toString()); 437 445 keyListener.keyTyped(ke); 438 446 return; … … 505 513 return; 506 514 } 507 508 for (Popup popup : PopupManager.getInstance().getPopups()) {515 final List<Popup> popups = PopupManager.getInstance().getPopups(); 516 for (Popup popup : popups) { 509 517 forwardNativeInputToListener(popup, event); 510 518 … … 520 528 return; 521 529 } 522 523 530 for (Widget iw : _widgets) { 524 531 java.awt.event.InputEvent e = respecInputEventForWidget(event, iw);
Note:
See TracChangeset
for help on using the changeset viewer.