mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Switch double modifier shortcuts to AWT event time
To resolve IDEA-187234 we need to use the same logic in typeahead implementation and the ModifierKeyDoubleClickHandler state machine
This commit is contained in:
+7
-8
@@ -11,7 +11,6 @@ import com.intellij.openapi.actionSystem.ex.AnActionListener;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.components.ApplicationComponent;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Clock;
|
||||
import com.intellij.openapi.util.Couple;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
@@ -155,12 +154,12 @@ public class ModifierKeyDoubleClickHandler implements Disposable, ApplicationCom
|
||||
resetState();
|
||||
return false;
|
||||
}
|
||||
if (myActionKeyCode == -1 && ourOtherKeyWasPressed.get() && Clock.getTime() - ourLastTimePressed.get() < 100) {
|
||||
if (myActionKeyCode == -1 && ourOtherKeyWasPressed.get() && keyEvent.getWhen() - ourLastTimePressed.get() < 100) {
|
||||
resetState();
|
||||
return false;
|
||||
}
|
||||
ourOtherKeyWasPressed.set(false);
|
||||
if (ourPressed.first.get() && Clock.getTime() - ourLastTimePressed.get() > 500) {
|
||||
if (ourPressed.first.get() && keyEvent.getWhen() - ourLastTimePressed.get() > 500) {
|
||||
resetState();
|
||||
}
|
||||
handleModifier((KeyEvent)event);
|
||||
@@ -174,7 +173,7 @@ public class ModifierKeyDoubleClickHandler implements Disposable, ApplicationCom
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
ourLastTimePressed.set(Clock.getTime());
|
||||
ourLastTimePressed.set(keyEvent.getWhen());
|
||||
ourOtherKeyWasPressed.set(true);
|
||||
if (keyCode == KeyEvent.VK_ESCAPE || keyCode == KeyEvent.VK_TAB) {
|
||||
ourLastTimePressed.set(0);
|
||||
@@ -196,7 +195,7 @@ public class ModifierKeyDoubleClickHandler implements Disposable, ApplicationCom
|
||||
}
|
||||
|
||||
private void handleModifier(KeyEvent event) {
|
||||
if (ourPressed.first.get() && Clock.getTime() - ourLastTimePressed.get() > 300) {
|
||||
if (ourPressed.first.get() && event.getWhen() - ourLastTimePressed.get() > 300) {
|
||||
resetState();
|
||||
return;
|
||||
}
|
||||
@@ -205,19 +204,19 @@ public class ModifierKeyDoubleClickHandler implements Disposable, ApplicationCom
|
||||
if (!ourPressed.first.get()) {
|
||||
resetState();
|
||||
ourPressed.first.set(true);
|
||||
ourLastTimePressed.set(Clock.getTime());
|
||||
ourLastTimePressed.set(event.getWhen());
|
||||
return;
|
||||
} else {
|
||||
if (ourPressed.first.get() && ourReleased.first.get()) {
|
||||
ourPressed.second.set(true);
|
||||
ourLastTimePressed.set(Clock.getTime());
|
||||
ourLastTimePressed.set(event.getWhen());
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if (event.getID() == KeyEvent.KEY_RELEASED) {
|
||||
if (ourPressed.first.get() && !ourReleased.first.get()) {
|
||||
ourReleased.first.set(true);
|
||||
ourLastTimePressed.set(Clock.getTime());
|
||||
ourLastTimePressed.set(event.getWhen());
|
||||
return;
|
||||
} else if (ourPressed.first.get() && ourReleased.first.get() && ourPressed.second.get()) {
|
||||
resetState();
|
||||
|
||||
Reference in New Issue
Block a user