mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-14 15:26:52 -04:00
Merge branch 'macCommandKey'
This commit is contained in:
commit
c20fd92b6b
@ -65,6 +65,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.filechooser.FileNameExtensionFilter;
|
import javax.swing.filechooser.FileNameExtensionFilter;
|
||||||
|
import javax.swing.text.DefaultEditorKit;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.datatransfer.Clipboard;
|
import java.awt.datatransfer.Clipboard;
|
||||||
import java.awt.datatransfer.DataFlavor;
|
import java.awt.datatransfer.DataFlavor;
|
||||||
@ -1878,6 +1879,11 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
|
|||||||
URL.setURLStreamHandlerFactory(ElementHelpDialog.createURLStreamHandlerFactory());
|
URL.setURLStreamHandlerFactory(ElementHelpDialog.createURLStreamHandlerFactory());
|
||||||
FormatToExpression.setDefaultFormat(Settings.getInstance().get(Keys.SETTINGS_EXPRESSION_FORMAT));
|
FormatToExpression.setDefaultFormat(Settings.getInstance().get(Keys.SETTINGS_EXPRESSION_FORMAT));
|
||||||
|
|
||||||
|
if (Screen.isMac()) {
|
||||||
|
setMacCopyPasteTo(UIManager.get("TextField.focusInputMap"));
|
||||||
|
setMacCopyPasteTo(UIManager.get("TextArea.focusInputMap"));
|
||||||
|
}
|
||||||
|
|
||||||
File file = null;
|
File file = null;
|
||||||
for (String s : args) {
|
for (String s : args) {
|
||||||
if (s.equals("experimental")) experimental = true;
|
if (s.equals("experimental")) experimental = true;
|
||||||
@ -1917,6 +1923,15 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void setMacCopyPasteTo(Object obj) {
|
||||||
|
if (obj instanceof InputMap) {
|
||||||
|
InputMap im = (InputMap) obj;
|
||||||
|
im.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.META_DOWN_MASK), DefaultEditorKit.copyAction);
|
||||||
|
im.put(KeyStroke.getKeyStroke(KeyEvent.VK_V, KeyEvent.META_DOWN_MASK), DefaultEditorKit.pasteAction);
|
||||||
|
im.put(KeyStroke.getKeyStroke(KeyEvent.VK_X, KeyEvent.META_DOWN_MASK), DefaultEditorKit.cutAction);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builder to create a Main-Window
|
* Builder to create a Main-Window
|
||||||
*/
|
*/
|
||||||
|
@ -7,6 +7,7 @@ package de.neemann.gui;
|
|||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Action to handle tool tips.
|
* Action to handle tool tips.
|
||||||
@ -83,7 +84,10 @@ public abstract class ToolTipAction extends AbstractAction {
|
|||||||
* @return this for call chaining
|
* @return this for call chaining
|
||||||
*/
|
*/
|
||||||
public ToolTipAction setAcceleratorCTRLplus(char key) {
|
public ToolTipAction setAcceleratorCTRLplus(char key) {
|
||||||
return setAccelerator(KeyStroke.getKeyStroke(key, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
|
int mask = KeyEvent.CTRL_DOWN_MASK;
|
||||||
|
if (Screen.isMac())
|
||||||
|
mask= KeyEvent.META_DOWN_MASK;
|
||||||
|
return setAccelerator(KeyStroke.getKeyStroke(key, mask));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user