diff options
Diffstat (limited to 'src/main/java/cc/polyfrost/oneconfig/gui')
-rw-r--r-- | src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java | 13 | ||||
-rw-r--r-- | src/main/java/cc/polyfrost/oneconfig/gui/elements/text/TextInputField.java | 19 |
2 files changed, 15 insertions, 17 deletions
diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java index 4103bca..668fdb3 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/ColorSelector.java @@ -1,6 +1,5 @@ package cc.polyfrost.oneconfig.gui.elements; -import cc.polyfrost.oneconfig.internal.assets.Colors; import cc.polyfrost.oneconfig.config.core.OneColor; import cc.polyfrost.oneconfig.gui.OneConfigGui; import cc.polyfrost.oneconfig.gui.animations.Animation; @@ -9,21 +8,21 @@ import cc.polyfrost.oneconfig.gui.animations.EaseInOutCubic; import cc.polyfrost.oneconfig.gui.animations.EaseInOutQuad; import cc.polyfrost.oneconfig.gui.elements.text.NumberInputField; import cc.polyfrost.oneconfig.gui.elements.text.TextInputField; +import cc.polyfrost.oneconfig.internal.assets.Colors; +import cc.polyfrost.oneconfig.internal.assets.Images; +import cc.polyfrost.oneconfig.internal.assets.SVGs; import cc.polyfrost.oneconfig.internal.config.OneConfigConfig; import cc.polyfrost.oneconfig.renderer.RenderManager; import cc.polyfrost.oneconfig.renderer.font.Fonts; -import cc.polyfrost.oneconfig.internal.assets.Images; -import cc.polyfrost.oneconfig.internal.assets.SVGs; import cc.polyfrost.oneconfig.renderer.scissor.Scissor; import cc.polyfrost.oneconfig.renderer.scissor.ScissorManager; +import cc.polyfrost.oneconfig.utils.IOUtils; import cc.polyfrost.oneconfig.utils.InputUtils; import cc.polyfrost.oneconfig.utils.NetworkUtils; import cc.polyfrost.oneconfig.utils.color.ColorPalette; import org.lwjgl.input.Mouse; import java.awt.*; -import java.awt.datatransfer.DataFlavor; -import java.awt.datatransfer.StringSelection; import java.util.ArrayList; public class ColorSelector { @@ -354,11 +353,11 @@ public class ColorSelector { private void parseHex() { if (copyBtn.isClicked()) { - Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(color.getHex()), null); + IOUtils.copyStringToClipboard(color.getHex()); } if (pasteBtn.isClicked() && mode != 2) { try { - color.setColorFromHex(Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null).getTransferData(DataFlavor.stringFlavor).toString()); + color.setColorFromHex(IOUtils.getStringFromClipboard()); hexInput.setInput("#" + color.getHex()); } catch (Exception ignored) { } diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/TextInputField.java b/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/TextInputField.java index f0f1447..c164eb6 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/TextInputField.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/elements/text/TextInputField.java @@ -1,24 +1,23 @@ package cc.polyfrost.oneconfig.gui.elements.text; -import cc.polyfrost.oneconfig.internal.assets.Colors; import cc.polyfrost.oneconfig.gui.elements.BasicElement; +import cc.polyfrost.oneconfig.internal.assets.Colors; +import cc.polyfrost.oneconfig.internal.assets.SVGs; +import cc.polyfrost.oneconfig.libs.universal.UKeyboard; import cc.polyfrost.oneconfig.renderer.RenderManager; import cc.polyfrost.oneconfig.renderer.font.Fonts; -import cc.polyfrost.oneconfig.internal.assets.SVGs; import cc.polyfrost.oneconfig.renderer.scissor.Scissor; import cc.polyfrost.oneconfig.renderer.scissor.ScissorManager; +import cc.polyfrost.oneconfig.utils.IOUtils; import cc.polyfrost.oneconfig.utils.InputUtils; import cc.polyfrost.oneconfig.utils.MathUtils; import cc.polyfrost.oneconfig.utils.TextUtils; -import cc.polyfrost.oneconfig.libs.universal.UKeyboard; import org.jetbrains.annotations.NotNull; import org.lwjgl.input.Keyboard; import org.lwjgl.input.Mouse; -import java.awt.*; -import java.awt.datatransfer.DataFlavor; -import java.awt.datatransfer.StringSelection; import java.util.ArrayList; +import java.util.Objects; public class TextInputField extends BasicElement { @@ -262,15 +261,15 @@ public class TextInputField extends BasicElement { if (toggled) { if (UKeyboard.isKeyComboCtrlC(key)) { if (selectedText != null && start != 0f && end != 0f) { - Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(selectedText), null); + IOUtils.copyStringToClipboard(selectedText); } return; } if (UKeyboard.isKeyComboCtrlV(key) || key == Keyboard.KEY_INSERT) { // TODO: find the UKeyboard equivalent for insert try { - String clip = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null).getTransferData(DataFlavor.stringFlavor).toString(); + String clip = IOUtils.getStringFromClipboard(); input = input.substring(0, caretPos) + clip + input.substring(caretPos); - caretPos = caretPos + clip.length(); + caretPos = caretPos + Objects.requireNonNull(clip).length(); return; } catch (Exception e) { e.printStackTrace(); @@ -307,7 +306,7 @@ public class TextInputField extends BasicElement { } if (UKeyboard.isKeyComboCtrlX(key)) { if (selectedText != null && start != 0f && end != 0f) { - Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(selectedText), null); + IOUtils.copyStringToClipboard(selectedText); key = UKeyboard.KEY_BACKSPACE; } else return; } |