mirror of
https://github.com/2009scape/2009Scape-mobile.git
synced 2025-12-21 09:01:56 -07:00
[Custom controls] Implements keycode send
This commit is contained in:
parent
8e34e8d398
commit
ea39de1d35
2 changed files with 23 additions and 4 deletions
|
|
@ -1073,11 +1073,11 @@ public class BaseMainActivity extends LoggableActivity {
|
||||||
// this.secondaryButton.setBackgroundDrawable(this.rightOverride ? this.secondaryButtonColorBackground : this.secondaryButtonDefaultBackground);
|
// this.secondaryButton.setBackgroundDrawable(this.rightOverride ? this.secondaryButtonColorBackground : this.secondaryButtonDefaultBackground);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendKeyPress(int keyCode, int modifiers, boolean status) {
|
public static void sendKeyPress(int keyCode, int modifiers, boolean status) {
|
||||||
sendKeyPress(keyCode, '\u0000', modifiers, status);
|
sendKeyPress(keyCode, '\u0000', modifiers, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendKeyPress(int keyCode, char keyChar, int modifiers, boolean status) {
|
public static void sendKeyPress(int keyCode, char keyChar, int modifiers, boolean status) {
|
||||||
CallbackBridge.sendKeycode(keyCode, keyChar, modifiers, status);
|
CallbackBridge.sendKeycode(keyCode, keyChar, modifiers, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -95,8 +95,7 @@ public class ControlButton extends Button implements OnLongClickListener, OnTouc
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onLongClick(View p1)
|
public boolean onLongClick(View p1) {
|
||||||
{
|
|
||||||
if (!mCanTriggerLongClick) return false;
|
if (!mCanTriggerLongClick) return false;
|
||||||
|
|
||||||
if (mHandleView.isShowing()) {
|
if (mHandleView.isShowing()) {
|
||||||
|
|
@ -116,7 +115,27 @@ public class ControlButton extends Button implements OnLongClickListener, OnTouc
|
||||||
public boolean onTouch(View view, MotionEvent event) {
|
public boolean onTouch(View view, MotionEvent event) {
|
||||||
if (!mCanModify) {
|
if (!mCanModify) {
|
||||||
mCanTriggerLongClick = false;
|
mCanTriggerLongClick = false;
|
||||||
|
|
||||||
|
if (mProperties.keycode >= 0) {
|
||||||
|
boolean isDown;
|
||||||
|
switch (event.getActionMasked()) {
|
||||||
|
case MotionEvent.ACTION_DOWN: // 0
|
||||||
|
case MotionEvent.ACTION_POINTER_DOWN: // 5
|
||||||
|
isDown = true;
|
||||||
|
break;
|
||||||
|
case MotionEvent.ACTION_UP: // 1
|
||||||
|
case MotionEvent.ACTION_CANCEL: // 3
|
||||||
|
case MotionEvent.ACTION_POINTER_UP: // 6
|
||||||
|
isDown = false;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
MainActivity.sendKeyPress(mProperties.keycode, 0, isDown);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue