diff --git a/src/android/accessibility/jar/src/org/qtproject/qt5/android/accessibility/QtAccessibilityDelegate.java b/src/android/accessibility/jar/src/org/qtproject/qt5/android/accessibility/QtAccessibilityDelegate.java index 70b02d8d04..3275b90e33 100644 --- a/src/android/accessibility/jar/src/org/qtproject/qt5/android/accessibility/QtAccessibilityDelegate.java +++ b/src/android/accessibility/jar/src/org/qtproject/qt5/android/accessibility/QtAccessibilityDelegate.java @@ -53,6 +53,7 @@ import android.text.TextUtils; import android.view.accessibility.*; import android.view.MotionEvent; +import android.view.View.OnHoverListener; import android.content.Context; @@ -85,9 +86,19 @@ public class QtAccessibilityDelegate extends View.AccessibilityDelegate // the offset of the view on screen into account (eg status bar on top) private final int[] m_globalOffset = new int[2]; + private class HoverEventListener implements View.OnHoverListener + { + @Override + public boolean onHover(View v, MotionEvent event) + { + return dispatchHoverEvent(event); + } + } + public QtAccessibilityDelegate(View host) { m_view = host; + m_view.setOnHoverListener(new HoverEventListener()); m_manager = (AccessibilityManager) host.getContext() .getSystemService(Context.ACCESSIBILITY_SERVICE); @@ -103,7 +114,7 @@ public class QtAccessibilityDelegate extends View.AccessibilityDelegate // For "explore by touch" we need all movement events here first // (user moves finger over screen to discover items on screen). - public boolean dispatchHoverEvent(MotionEvent event) + private boolean dispatchHoverEvent(MotionEvent event) { if (!m_manager.isTouchExplorationEnabled()) { return false; diff --git a/src/android/jar/src/org/qtproject/qt5/android/QtSurface.java b/src/android/jar/src/org/qtproject/qt5/android/QtSurface.java index 45a80a3dbb..ca3f20f11b 100644 --- a/src/android/jar/src/org/qtproject/qt5/android/QtSurface.java +++ b/src/android/jar/src/org/qtproject/qt5/android/QtSurface.java @@ -110,24 +110,6 @@ public class QtSurface extends SurfaceView implements SurfaceHolder.Callback } } - public boolean dispatchHoverEvent(MotionEvent event) { - // Always attempt to dispatch hover events to accessibility first. - if (m_accessibilityDelegate != null) { - try { - Method dispHoverA11y = m_accessibilityDelegate.getClass().getMethod("dispatchHoverEvent", MotionEvent.class); - boolean ret = (Boolean) dispHoverA11y.invoke(m_accessibilityDelegate, event); - if (ret) - return true; - SurfaceView view = (SurfaceView) this; - Method dispHoverView = view.getClass().getMethod("dispatchHoverEvent", MotionEvent.class); - return (Boolean) dispHoverView.invoke(view, event); - } catch (Exception e) { - Log.w("Qt A11y", "EXCEPTION in dispatchHoverEvent for Accessibility: " + e); - } - } - return false; - } - @Override public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {