8166772: Touch keyboard is not shown for text components on a screen touch

Reviewed-by: serb, azvegint
This commit is contained in:
Anton Litvinov 2017-10-11 15:53:25 +01:00
parent a9cb8eb350
commit dd41b7691f
24 changed files with 726 additions and 13 deletions

View file

@ -5022,6 +5022,12 @@ public abstract class Component implements ImageObserver, MenuContainer,
tpeer.handleEvent(e);
}
}
if (SunToolkit.isTouchKeyboardAutoShowEnabled() &&
(toolkit instanceof SunToolkit) &&
((e instanceof MouseEvent) || (e instanceof FocusEvent))) {
((SunToolkit)toolkit).showOrHideTouchKeyboard(this, e);
}
} // dispatchEventImpl()
/*

View file

@ -55,6 +55,7 @@ import sun.util.logging.PlatformLogger;
import sun.awt.AppContext;
import sun.awt.AWTAccessor;
import sun.awt.AWTAccessor.MouseEventAccessor;
import sun.awt.PeerEvent;
import sun.awt.SunToolkit;
@ -4783,6 +4784,9 @@ class LightweightDispatcher implements java.io.Serializable, AWTEventListener {
srcEvent.getClickCount(),
srcEvent.isPopupTrigger(),
srcEvent.getButton());
MouseEventAccessor meAccessor = AWTAccessor.getMouseEventAccessor();
meAccessor.setCausedByTouchEvent(me,
meAccessor.isCausedByTouchEvent(srcEvent));
((AWTEvent)srcEvent).copyPrivateDataInto(me);
// translate coordinates to this native container
final Point ptSrcOrigin = srcComponent.getLocationOnScreen();
@ -4884,6 +4888,9 @@ class LightweightDispatcher implements java.io.Serializable, AWTEventListener {
e.getClickCount(),
e.isPopupTrigger(),
e.getButton());
MouseEventAccessor meAccessor = AWTAccessor.getMouseEventAccessor();
meAccessor.setCausedByTouchEvent(retargeted,
meAccessor.isCausedByTouchEvent(e));
}
((AWTEvent)e).copyPrivateDataInto(retargeted);

View file

@ -33,6 +33,8 @@ import java.io.IOException;
import java.io.ObjectInputStream;
import java.awt.IllegalComponentStateException;
import java.awt.MouseInfo;
import sun.awt.AWTAccessor;
import sun.awt.SunToolkit;
/**
@ -331,6 +333,11 @@ public class MouseEvent extends InputEvent {
*/
int clickCount;
/**
* Indicates whether the event is a result of a touch event.
*/
private boolean causedByTouchEvent;
/**
* Indicates which, if any, of the mouse buttons has changed state.
*
@ -399,6 +406,17 @@ public class MouseEvent extends InputEvent {
//whatever besides SunToolkit) could also operate.
cachedNumberOfButtons = 3;
}
AWTAccessor.setMouseEventAccessor(
new AWTAccessor.MouseEventAccessor() {
public boolean isCausedByTouchEvent(MouseEvent ev) {
return ev.causedByTouchEvent;
}
public void setCausedByTouchEvent(MouseEvent ev,
boolean causedByTouchEvent) {
ev.causedByTouchEvent = causedByTouchEvent;
}
});
}
/**