5package io.flutter.plugin.mouse;
7import static io.flutter.Build.API_LEVELS;
9import android.annotation.TargetApi;
11import androidx.annotation.NonNull;
12import androidx.annotation.RequiresApi;
13import io.flutter.embedding.engine.systemchannels.MouseCursorChannel;
14import java.util.HashMap;
27 this.mouseCursorChannel = mouseCursorChannel;
28 mouseCursorChannel.setMethodHandler(
31 public void activateSystemCursor(@NonNull String kind) {
32 mView.setPointerIcon(resolveSystemCursor(kind));
42 private PointerIcon resolveSystemCursor(@NonNull String kind) {
43 if (MouseCursorPlugin.systemCursorConstants ==
null) {
46 MouseCursorPlugin.systemCursorConstants =
47 new HashMap<String, Integer>() {
48 private static final long serialVersionUID = 1
L;
51 put(
"alias", PointerIcon.TYPE_ALIAS);
52 put(
"allScroll", PointerIcon.TYPE_ALL_SCROLL);
53 put(
"basic", PointerIcon.TYPE_ARROW);
54 put(
"cell", PointerIcon.TYPE_CELL);
55 put(
"click", PointerIcon.TYPE_HAND);
56 put(
"contextMenu", PointerIcon.TYPE_CONTEXT_MENU);
57 put(
"copy", PointerIcon.TYPE_COPY);
58 put(
"forbidden", PointerIcon.TYPE_NO_DROP);
59 put(
"grab", PointerIcon.TYPE_GRAB);
60 put(
"grabbing", PointerIcon.TYPE_GRABBING);
61 put(
"help", PointerIcon.TYPE_HELP);
62 put(
"move", PointerIcon.TYPE_ALL_SCROLL);
63 put(
"none", PointerIcon.TYPE_NULL);
64 put(
"noDrop", PointerIcon.TYPE_NO_DROP);
65 put(
"precise", PointerIcon.TYPE_CROSSHAIR);
66 put(
"text", PointerIcon.TYPE_TEXT);
67 put(
"resizeColumn", PointerIcon.TYPE_HORIZONTAL_DOUBLE_ARROW);
68 put(
"resizeDown", PointerIcon.TYPE_VERTICAL_DOUBLE_ARROW);
69 put(
"resizeUpLeft", PointerIcon.TYPE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW);
70 put(
"resizeDownRight", PointerIcon.TYPE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW);
71 put(
"resizeLeft", PointerIcon.TYPE_HORIZONTAL_DOUBLE_ARROW);
72 put(
"resizeLeftRight", PointerIcon.TYPE_HORIZONTAL_DOUBLE_ARROW);
73 put(
"resizeRight", PointerIcon.TYPE_HORIZONTAL_DOUBLE_ARROW);
74 put(
"resizeRow", PointerIcon.TYPE_VERTICAL_DOUBLE_ARROW);
75 put(
"resizeUp", PointerIcon.TYPE_VERTICAL_DOUBLE_ARROW);
76 put(
"resizeUpDown", PointerIcon.TYPE_VERTICAL_DOUBLE_ARROW);
77 put(
"resizeUpLeft", PointerIcon.TYPE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW);
78 put(
"resizeUpRight", PointerIcon.TYPE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW);
79 put(
"resizeUpLeftDownRight", PointerIcon.TYPE_TOP_LEFT_DIAGONAL_DOUBLE_ARROW);
80 put(
"resizeUpRightDownLeft", PointerIcon.TYPE_TOP_RIGHT_DIAGONAL_DOUBLE_ARROW);
81 put(
"verticalText", PointerIcon.TYPE_VERTICAL_TEXT);
82 put(
"wait", PointerIcon.TYPE_WAIT);
83 put(
"zoomIn", PointerIcon.TYPE_ZOOM_IN);
84 put(
"zoomOut", PointerIcon.TYPE_ZOOM_OUT);
89 final int cursorConstant =
90 MouseCursorPlugin.systemCursorConstants.getOrDefault(kind, PointerIcon.TYPE_ARROW);
91 return mView.getSystemPointerIcon(cursorConstant);
100 mouseCursorChannel.setMethodHandler(
null);
109 @NonNull
private static HashMap<String, Integer> systemCursorConstants;
MouseCursorPlugin( @NonNull MouseCursorViewDelegate view, @NonNull MouseCursorChannel mouseCursorChannel)
void setPointerIcon(@NonNull PointerIcon icon)
PointerIcon getSystemPointerIcon(int type)