Skip to content

Commit 39a6df5

Browse files
committed
Fixed issue with tabs component capturing swipe events when higher components should block it. Fixes #3642
1 parent f8a7c5c commit 39a6df5

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

CodenameOne/src/com/codename1/ui/Tabs.java

+21-1
Original file line numberDiff line numberDiff line change
@@ -1431,6 +1431,8 @@ public SwipeListener(int type) {
14311431
this.type = type;
14321432
}
14331433

1434+
1435+
14341436
public void actionPerformed(ActionEvent evt) {
14351437

14361438
if (getComponentCount() == 0 || !swipeActivated ||slideToDestMotion != null) {
@@ -1442,7 +1444,7 @@ public void actionPerformed(ActionEvent evt) {
14421444
case PRESS: {
14431445
blockSwipe = false;
14441446
riskySwipe = false;
1445-
if (contentPane.visibleBoundsContains(x, y)) {
1447+
if (!isEventBlockedByHigherComponent(evt) && contentPane.visibleBoundsContains(x, y)) {
14461448
Component testCmp = contentPane.getComponentAt(x, y);
14471449
if(testCmp != null && testCmp != contentPane) {
14481450
doNotBlockSideSwipe = true;
@@ -1656,6 +1658,24 @@ public void actionPerformed(ActionEvent evt) {
16561658
}
16571659
}
16581660
}
1661+
1662+
private boolean isEventBlockedByHigherComponent(ActionEvent evt) {
1663+
final int x = evt.getX();
1664+
final int y = evt.getY();
1665+
final Form currentForm = Display.INSTANCE.getCurrent();
1666+
if (currentForm == null) {
1667+
return false;
1668+
}
1669+
final Component targetComponent = currentForm.getComponentAt(x, y);
1670+
if (targetComponent == null) {
1671+
return false;
1672+
}
1673+
if (contentPane.equals(targetComponent) || contentPane.contains(targetComponent)) {
1674+
return false;
1675+
}
1676+
1677+
return true;
1678+
}
16591679
}
16601680

16611681
/**

0 commit comments

Comments
 (0)