forked from extern/Unexpected-Keyboard
Disable automatically Shift when pressing Ctrl
Automatic capitalisation might interferes with keyboard shortcuts.
This commit is contained in:
parent
cf76118548
commit
f4c11d99ed
@ -77,6 +77,13 @@ final class Autocapitalisation
|
||||
callback(true);
|
||||
}
|
||||
|
||||
public void stop()
|
||||
{
|
||||
_should_enable_shift = false;
|
||||
_should_update_caps_mode = false;
|
||||
callback(true);
|
||||
}
|
||||
|
||||
public static interface Callback
|
||||
{
|
||||
public void update_shift_state(boolean should_enable, boolean should_disable);
|
||||
|
@ -359,6 +359,7 @@ final class Config
|
||||
|
||||
public static interface IKeyEventHandler
|
||||
{
|
||||
public void key_down(KeyValue value, boolean is_swipe);
|
||||
public void key_up(KeyValue value, Pointers.Modifiers flags);
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,29 @@ class KeyEventHandler implements Config.IKeyEventHandler
|
||||
_autocap.selection_updated(oldSelStart, newSelStart);
|
||||
}
|
||||
|
||||
/** A key is being pressed. There will not necessarily be a corresponding
|
||||
[key_up] event. */
|
||||
public void key_down(KeyValue key, boolean isSwipe)
|
||||
{
|
||||
if (key == null)
|
||||
return;
|
||||
switch (key.getKind())
|
||||
{
|
||||
case Modifier:
|
||||
// Stop auto capitalisation when activating a system modifier
|
||||
switch (key.getModifier())
|
||||
{
|
||||
case CTRL:
|
||||
case ALT:
|
||||
case META:
|
||||
_autocap.stop();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
/** A key has been released. */
|
||||
public void key_up(KeyValue key, Pointers.Modifiers mods)
|
||||
{
|
||||
|
@ -113,7 +113,7 @@ public class Keyboard2View extends View
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((flags & KeyValue.FLAG_FAKE_PTR) != 0)
|
||||
if ((flags & KeyValue.FLAG_FAKE_PTR) == 0)
|
||||
return; // Don't remove locked pointers
|
||||
_pointers.remove_fake_pointer(_shift_kv, _shift_key);
|
||||
}
|
||||
@ -134,8 +134,9 @@ public class Keyboard2View extends View
|
||||
return KeyModifier.modify(k, mods);
|
||||
}
|
||||
|
||||
public void onPointerDown(boolean isSwipe)
|
||||
public void onPointerDown(KeyValue k, boolean isSwipe)
|
||||
{
|
||||
_config.handler.key_down(k, isSwipe);
|
||||
invalidate();
|
||||
vibrate();
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ public final class Pointers implements Handler.Callback
|
||||
Pointer ptr = new Pointer(pointerId, key, value, x, y, mods);
|
||||
_ptrs.add(ptr);
|
||||
startKeyRepeat(ptr);
|
||||
_handler.onPointerDown(false);
|
||||
_handler.onPointerDown(value, false);
|
||||
}
|
||||
|
||||
static final int[] DIRECTION_TO_INDEX = new int[]{
|
||||
@ -263,7 +263,7 @@ public final class Pointers implements Handler.Callback
|
||||
{
|
||||
startSliding(ptr, dy);
|
||||
}
|
||||
_handler.onPointerDown(true);
|
||||
_handler.onPointerDown(newValue, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -383,7 +383,7 @@ public final class Pointers implements Handler.Callback
|
||||
{
|
||||
ptr.value = kv;
|
||||
ptr.flags = kv.getFlags();
|
||||
_handler.onPointerDown(true);
|
||||
_handler.onPointerDown(kv, true);
|
||||
return true;
|
||||
}
|
||||
// Stop repeating: Special keys
|
||||
@ -522,8 +522,9 @@ public final class Pointers implements Handler.Callback
|
||||
public KeyValue modifyKey(KeyValue k, Modifiers flags);
|
||||
|
||||
/** A key is pressed. [getModifiers()] is uptodate. Might be called after a
|
||||
press or a swipe to a different value. */
|
||||
public void onPointerDown(boolean isSwipe);
|
||||
press or a swipe to a different value. Down events are not paired with
|
||||
up events. */
|
||||
public void onPointerDown(KeyValue k, boolean isSwipe);
|
||||
|
||||
/** Key is released. [k] is the key that was returned by
|
||||
[modifySelectedKey] or [modifySelectedKey]. */
|
||||
|
Loading…
Reference in New Issue
Block a user