Home | 简体中文 | 繁体中文 | 杂文 | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

110.7. 鼠标事件

		
        binding.storyFullscreenFrameLayout.setOnGenericMotionListener(new View.OnGenericMotionListener() {
            @Override
            public boolean onGenericMotion(View v, MotionEvent event) {
                Log.d(TAG, "onGenericMotion: " + event.toString());
                if (event.getActionButton() == MotionEvent.BUTTON_PRIMARY) {
//                    Log.d(TAG, "鼠标左键");
//                    broadcastToast("左键");
                    if (event.getAction() == MotionEvent.ACTION_BUTTON_PRESS) {
                        microphoneDown();
//                        broadcastToast(event.toString());
                    }
                    if (event.getAction() == MotionEvent.ACTION_BUTTON_RELEASE) {
                        microphoneUp();
//                        broadcastToast(event.toString());
                    }
                }
                if (event.getButtonState() == MotionEvent.BUTTON_SECONDARY) {
                    Log.d(TAG, "鼠标右键");
//                    broadcastToast("右键");
                }
                if (event.getButtonState() == MotionEvent.BUTTON_TERTIARY) {
                    Log.d(TAG, "鼠标中间键");
//                    broadcastToast("中间键");
                }
                return false;
            }
        });