Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions android/src/main/java/com/reactnativemenu/MenuView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,18 @@ class MenuView(private val mContext: ReactContext) : ReactViewGroup(mContext) {
prepareMenu()
}

override fun addView(child: View?, index: Int, params: ViewGroup.LayoutParams?) {
super.addView(child, index, params)
// Make child views trigger menu when clicked via TalkBack
child?.let {
it.isClickable = true
it.isFocusable = true
it.setOnClickListener {
performClick()
}
}
}

override fun onInterceptTouchEvent(ev: MotionEvent): Boolean {
return true
}
Expand All @@ -61,6 +73,14 @@ class MenuView(private val mContext: ReactContext) : ReactViewGroup(mContext) {
return true
}

override fun performClick(): Boolean {
super.performClick()
if (!mIsOnLongPress) {
prepareMenu()
}
return true
}

override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
super.onSizeChanged(w, h, oldw, oldh)
updateTouchDelegate()
Expand Down