Bläddra i källkod

Detect new and old names for apple look and feel.

Fix Apple Menu Items to actually work for the first time since November 2010 (db95f29d75)
This should probably be backported also along with I6b31f255981dd064ef19bea2b84e8389d63e71c3 but is less important.

Change-Id: I325f91b0a2f9cf033f47138330abad132a77bf9a
Reviewed-on: http://gerrit.dmdirc.com/2467
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Greg Holmes <greg@dmdirc.com>
tags/0.7rc1
Shane Mc Cormack 12 år sedan
förälder
incheckning
79056d1075
1 ändrade filer med 9 tillägg och 6 borttagningar
  1. 9
    6
      src/com/dmdirc/addons/ui_swing/Apple.java

+ 9
- 6
src/com/dmdirc/addons/ui_swing/Apple.java Visa fil

@@ -33,7 +33,6 @@ import com.dmdirc.interfaces.actions.ActionType;
33 33
 import com.dmdirc.logger.ErrorLevel;
34 34
 import com.dmdirc.logger.Logger;
35 35
 
36
-import java.awt.Toolkit;
37 36
 import java.awt.event.ActionEvent;
38 37
 import java.lang.reflect.Field;
39 38
 import java.lang.reflect.InvocationHandler;
@@ -218,8 +217,8 @@ public final class Apple implements InvocationHandler, ActionListener {
218 217
      * @return true if we are using the OS X look and feel
219 218
      */
220 219
     public static boolean isAppleUI() {
221
-        return isApple() && UIManager.getLookAndFeel().getClass().getName().
222
-                equals("apple.laf.AquaLookAndFeel");
220
+        final String name = UIManager.getLookAndFeel().getClass().getName();
221
+        return isApple() && (name.equals("apple.laf.AquaLookAndFeel") || name.equals("com.apple.laf.AquaLookAndFeel"));
223 222
     }
224 223
 
225 224
     /**
@@ -395,12 +394,16 @@ public final class Apple implements InvocationHandler, ActionListener {
395 394
         if (!isApple() || menuBar == null) {
396 395
             return;
397 396
         }
398
-        event.setHandled(true);
399 397
         final ActionEvent actionEvent = new ActionEvent(this,
400 398
                 ActionEvent.ACTION_PERFORMED, name);
401 399
 
402
-        Toolkit.getDefaultToolkit().getSystemEventQueue()
403
-                .postEvent(actionEvent);
400
+        for (int i = 0; i < menuBar.getMenuCount(); i++) {
401
+            final JMenu menu = menuBar.getMenu(i);
402
+            if (menu instanceof java.awt.event.ActionListener) {
403
+                ((java.awt.event.ActionListener)menu).actionPerformed(actionEvent);
404
+                event.setHandled(true);
405
+            }
406
+        }
404 407
     }
405 408
 
406 409
     /**

Laddar…
Avbryt
Spara