android-reactions icon indicating copy to clipboard operation
android-reactions copied to clipboard

Delegate Touch Event Without lifting the finger

Open lazy-coder-10 opened this issue 2 years ago • 1 comments

How can I select an item without lifting the finger on a long press? I have implemented the long-press but unable to select items I have to release my finger than only I am able to select the items. Would be great if you can help me.

lazy-coder-10 avatar Jul 12 '21 10:07 lazy-coder-10

You can use the below mentioned code in the block of setReactions function, this is the only way to do achieve long press without lifting a finger. reactionBtutton.setOnTouchListener(popup) reactionBtutton.setOnTouchListener { arg0, arg1 -> when (arg1.action) { MotionEvent.ACTION_DOWN -> { timer = Timer() timer.schedule(object : TimerTask() { override fun run() { CoroutineScope( Dispatchers.Main ).launch { popup.onTouch(arg0, arg1) } } }, 300) //time out 1/2s } MotionEvent.ACTION_UP -> { timer.cancel() } else -> false } false }

TalverseZaidi avatar Mar 31 '22 20:03 TalverseZaidi