Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
PlatformOverlayView.java
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5package io.flutter.plugin.platform;
6
7import android.content.Context;
8import android.util.AttributeSet;
9import android.view.MotionEvent;
10import androidx.annotation.NonNull;
11import androidx.annotation.Nullable;
12import io.flutter.embedding.android.FlutterImageView;
13
14/** A host view for Flutter content displayed over a platform view. */
15public class PlatformOverlayView extends FlutterImageView {
16 @Nullable private AccessibilityEventsDelegate accessibilityDelegate;
17
19 @NonNull Context context,
20 int width,
21 int height,
22 @NonNull AccessibilityEventsDelegate accessibilityDelegate) {
23 super(context, width, height, FlutterImageView.SurfaceKind.overlay);
24 this.accessibilityDelegate = accessibilityDelegate;
25 }
26
27 public PlatformOverlayView(@NonNull Context context) {
28 this(context, 1, 1, null);
29 }
30
31 public PlatformOverlayView(@NonNull Context context, @NonNull AttributeSet attrs) {
32 this(context, 1, 1, null);
33 }
34
35 @Override
36 public boolean onHoverEvent(@NonNull MotionEvent event) {
37 // This view doesn't have any accessibility information of its own, but anything drawn in
38 // this view is visible above the platform view it is overlaying, so should respond to
39 // accessibility exploration events. Forward those events to the accessibility delegate in
40 // a special mode that will stop as soon as it reaches a platform view, so that it will not
41 // find widgets that behind the platform view. If no such widget is found, treat the event
42 // as unhandled so that it can fall through to the platform view.
43 if (accessibilityDelegate != null
44 && accessibilityDelegate.onAccessibilityHoverEvent(event, true)) {
45 return true;
46 }
47 return super.onHoverEvent(event);
48 }
49}
boolean onHoverEvent(@NonNull MotionEvent event)
PlatformOverlayView(@NonNull Context context, @NonNull AttributeSet attrs)
PlatformOverlayView( @NonNull Context context, int width, int height, @NonNull AccessibilityEventsDelegate accessibilityDelegate)
FlKeyEvent * event
int32_t height
int32_t width