55import net .minecraft .client .Minecraft ;
66import net .minecraft .client .gui .components .AbstractWidget ;
77import net .minecraft .client .gui .components .EditBox ;
8- import net .minecraft .client .gui .screens .Screen ;
8+ import net .minecraft .client .input .InputQuirks ;
9+ import net .minecraft .client .input .KeyEvent ;
910import net .minecraft .network .chat .Component ;
1011import org .spongepowered .asm .mixin .Mixin ;
1112import org .spongepowered .asm .mixin .Shadow ;
@@ -41,11 +42,12 @@ public EditBoxMixin(int x, int y, int width, int height, Component message) {
4142 at = @ At ("HEAD" ),
4243 cancellable = true
4344 )
44- private void onDeleteText (int count , CallbackInfo ci ) {
45- if (Minecraft .ON_OSX && EssentialClientConfig .getInstance ().getFixMacOSCursorJumping ()) {
46- if (Screen .hasControlDown ()) {
45+ private void onDeleteText (int count , boolean bl , CallbackInfo ci ) {
46+ if (InputQuirks .REPLACE_CTRL_KEY_WITH_CMD_KEY && EssentialClientConfig .getInstance ().getFixMacOSCursorJumping ()) {
47+ Minecraft minecraft = Minecraft .getInstance ();
48+ if (minecraft .hasControlDown ()) {
4749 this .insertText ("" );
48- } else if (Screen .hasAltDown ()) {
50+ } else if (minecraft .hasAltDown ()) {
4951 this .deleteWords (count );
5052 } else {
5153 this .deleteChars (count );
@@ -60,27 +62,27 @@ private void onDeleteText(int count, CallbackInfo ci) {
6062 at = @ At ("HEAD" ),
6163 cancellable = true
6264 )
63- private void onKeyPressed (int keyCode , int scanCode , int modifiers , CallbackInfoReturnable <Boolean > cir ) {
65+ private void onKeyPressed (KeyEvent event , CallbackInfoReturnable <Boolean > cir ) {
6466 if (this .isActive () && this .isFocused ()) {
65- if (Minecraft . ON_OSX && EssentialClientConfig .getInstance ().getFixMacOSCursorJumping ()) {
66- switch (keyCode ) {
67+ if (InputQuirks . REPLACE_CTRL_KEY_WITH_CMD_KEY && EssentialClientConfig .getInstance ().getFixMacOSCursorJumping ()) {
68+ switch (event . key () ) {
6769 case InputConstants .KEY_RIGHT -> {
68- if (Screen .hasControlDown ()) {
69- this .moveCursorToEnd (Screen .hasShiftDown ());
70- } else if (Screen .hasAltDown ()) {
71- this .moveCursorTo (this .getWordPosition (1 ), Screen .hasShiftDown ());
70+ if (event .hasControlDown ()) {
71+ this .moveCursorToEnd (event .hasShiftDown ());
72+ } else if (event .hasAltDown ()) {
73+ this .moveCursorTo (this .getWordPosition (1 ), event .hasShiftDown ());
7274 } else {
73- this .moveCursor (1 , Screen .hasShiftDown ());
75+ this .moveCursor (1 , event .hasShiftDown ());
7476 }
7577 cir .setReturnValue (true );
7678 }
7779 case InputConstants .KEY_LEFT -> {
78- if (Screen .hasControlDown ()) {
79- this .moveCursorToStart (Screen .hasShiftDown ());
80- } else if (Screen .hasAltDown ()) {
81- this .moveCursorTo (this .getWordPosition (-1 ), Screen .hasShiftDown ());
80+ if (event .hasControlDown ()) {
81+ this .moveCursorToStart (event .hasShiftDown ());
82+ } else if (event .hasAltDown ()) {
83+ this .moveCursorTo (this .getWordPosition (-1 ), event .hasShiftDown ());
8284 } else {
83- this .moveCursor (-1 , Screen .hasShiftDown ());
85+ this .moveCursor (-1 , event .hasShiftDown ());
8486 }
8587 cir .setReturnValue (true );
8688 }
0 commit comments