Skip to content

Commit

Permalink
Fixed issue with tabs component capturing swipe events when higher co…
Browse files Browse the repository at this point in the history
…mponents should block it. Fixes #3642
  • Loading branch information
shannah committed Oct 30, 2022
1 parent f8a7c5c commit 39a6df5
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion CodenameOne/src/com/codename1/ui/Tabs.java
Original file line number Diff line number Diff line change
Expand Up @@ -1431,6 +1431,8 @@ public SwipeListener(int type) {
this.type = type;
}



public void actionPerformed(ActionEvent evt) {

if (getComponentCount() == 0 || !swipeActivated ||slideToDestMotion != null) {
Expand All @@ -1442,7 +1444,7 @@ public void actionPerformed(ActionEvent evt) {
case PRESS: {
blockSwipe = false;
riskySwipe = false;
if (contentPane.visibleBoundsContains(x, y)) {
if (!isEventBlockedByHigherComponent(evt) && contentPane.visibleBoundsContains(x, y)) {
Component testCmp = contentPane.getComponentAt(x, y);
if(testCmp != null && testCmp != contentPane) {
doNotBlockSideSwipe = true;
Expand Down Expand Up @@ -1656,6 +1658,24 @@ public void actionPerformed(ActionEvent evt) {
}
}
}

private boolean isEventBlockedByHigherComponent(ActionEvent evt) {
final int x = evt.getX();
final int y = evt.getY();
final Form currentForm = Display.INSTANCE.getCurrent();
if (currentForm == null) {
return false;
}
final Component targetComponent = currentForm.getComponentAt(x, y);
if (targetComponent == null) {
return false;
}
if (contentPane.equals(targetComponent) || contentPane.contains(targetComponent)) {
return false;
}

return true;
}
}

/**
Expand Down

0 comments on commit 39a6df5

Please sign in to comment.