mirror of
https://github.com/AngelAuraMC/Amethyst-Android.git
synced 2026-07-30 10:16:51 -04:00
fix(HotbarView): #37
This commit is contained in:
@@ -501,6 +501,10 @@ public class MainActivity extends BaseActivity implements ControlButtonMenuListe
|
||||
Tools.runOnUiThread(()-> mServiceBinder.isActive = false);
|
||||
}
|
||||
|
||||
public void setmLastIndex(int a){
|
||||
mHotbarView.setmLastIndex(a);
|
||||
}
|
||||
|
||||
private void dialogSendCustomKey() {
|
||||
AlertDialog.Builder dialog = new AlertDialog.Builder(this);
|
||||
dialog.setTitle(R.string.control_customkey);
|
||||
|
||||
@@ -97,6 +97,10 @@ public class HotbarView extends View implements MCOptionUtils.MCOptionListener,
|
||||
setLayoutParams(marginLayoutParams);
|
||||
}
|
||||
|
||||
public void setmLastIndex(int mLastIndex) {
|
||||
this.mLastIndex = mLastIndex;
|
||||
}
|
||||
|
||||
@SuppressWarnings("ClickableViewAccessibility") // performClick does not report coordinates.
|
||||
@Override
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
|
||||
@@ -8,6 +8,7 @@ import android.content.*;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.view.Choreographer;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
@@ -93,6 +94,13 @@ public class CallbackBridge {
|
||||
if(isDown){
|
||||
SDLActivity.onNativeKeyDown(EfficientAndroidLWJGLKeycode.getAndroidKeycode(keycode));
|
||||
} else SDLActivity.onNativeKeyUp(EfficientAndroidLWJGLKeycode.getAndroidKeycode(keycode));
|
||||
// If not in GUI and pressed a hotbar key, update HotbarView's last index for gesture
|
||||
// detection. This is still faulty but should be less so.
|
||||
if (isGrabbing()){
|
||||
if (keycode >= LwjglGlfwKeycode.GLFW_KEY_0 && keycode <= LwjglGlfwKeycode.GLFW_KEY_9){
|
||||
((MainActivity) SDLActivity.getContext()).setmLastIndex(keycode - LwjglGlfwKeycode.GLFW_KEY_0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendChar(char keychar, int modifiers){
|
||||
|
||||
Reference in New Issue
Block a user