-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Stacked Label elements doesn't pass-thru tap events (iOS) #3524
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hey @erjdriver To prevent the label which is stacked on top to "steal" the tap you can use isUserInteractionEnabled boolean property and set it to false for your top label. This will not only dismiss all gestures for that label but will allow you to detect the gestures for the label positioned below in the visual stack. For example: page.xml
page.ts
Now tapping on label one (even if label two is in front of it) will always trigger. |
My apologies - I forgot to mention that. I tried it and it still didn't work. Though I tried it in code - not xml. label2.isUserInteractionEnabled = false; Again this problem is in iOS. It works on Android even w/o the above setting of isUserInteractionEnabled. Since you took the trouble of testing it - I will go back and test it again. p.s. i did notice that your coordinates for the 2 labels are not overlapping. What happens if you set label #2 coords to the same as that of #1. |
Actually - yes it does work! Originally, I had entered the correct code but the taps were not registering on label #1 - but this was because of another {N} issue - which I think has been fixed in the upcoming release. Thanks again. |
Interestingly, on Android platform - if you set the isUserInteractionEnabled to false - it doesn't pass thru any events. |
@erjdriver have you been able to solve this consistently for both platforms? |
On iOS - i've got to set isUserInteractionEnabled to false explicitly. It works without setting explicitly on the Android. |
I'm experiencing this issue right now. Works in Android, doesn't work in iOS. What I've done is used the AbsoluteLayout to position a StackLayout on top of a GridLayout. The layer on top has a Slider which needs to be interactive and beneath it are labels that are tappable. You can swipe left/right the foreground layer to expose the menu items of the background layer from behind. So I'm going to look into the Kind of a bummer that I need to do this :/ Obviously, when the background menu is closed by either interaction or swipe, I need to set PS originally I used the RadListView for the swiping to show the menus below, but when I enabled swiping, the ability to use the Slider stopped working. And not to confuse you, there are two swiping gestures in this UI. One to set the gauge of something and two to expose the background menu. Works in Android! Update: Updated my code to turn on/off the My View code: <StackLayout *ngFor="let feeling of feelings;let i = index" class="feeling-gauge-input-parent">
<!-- Header: Emotion's name and emoticon representing sentimental score -->
<AbsoluteLayout class="feeling-gauge-input">
<!-- Background (menu) -->
<GridLayout class="actions" rows="*" columns="auto, *, auto">
<Label col="0" text="Remove" class="edit add-gutter" (tap)="deleteFeeling(i)"></Label>
<Label col="1"></Label>
<StackLayout col="2" class="edit">
<yf-sentiment-changer [(sentiment)]="feeling.sentiment"></yf-sentiment-changer>
</StackLayout>
</GridLayout>
<!-- Foreground: Feeling Gauge/Sentiment Input -->
<StackLayout class="feeling-gauge-input-container">
<StackLayout orientation="horizontal" #panlayers (pan)="onFeelingHeadPan($event, i)" class="header add-gutter-hack">
<Label [text]="feeling.name | howMuchFeeling"></Label>
<yf-feeling-emoticon [sentiment]="feeling.sentiment" [gauge]="feeling.gauge"></yf-feeling-emoticon>
</StackLayout>
</StackLayout>
</AbsoluteLayout>
<!-- Footer: Scale to adjust the Feeling's gauge that directly effects opacity of above emoticon -->
<Slider
minValue="0" maxValue="100" value="0"
[(ngModel)]="feeling.gauge" [ngModelOptions]="{standalone: true}" class="add-gutter gauge-slider"></Slider>
</StackLayout> What I was trying to do was on pan end, toggle the property, but even so, that won't be perfect for the UX because then the User won't be able to close the open menu without clicking an item or something :/ Some TS: // high up at the beginning of the class declaration
@ViewChildren('panlayers') foregrounds:QueryList<StackLayout>;
// somewhere in the pan handle function......
if (isIOS) {
if (destX !== 0) {
// we have opened the menu, let's freeze user interactions with the above layer
console.log('turn off isUserInteractionEnabled on foregrounds');
this.foregrounds.forEach((foreground) => {
foreground.isUserInteractionEnabled = false;
});
} else {
// we closed the menu so let's return the normal functioning tap events to the above layer
console.log('turn on isUserInteractionEnabled on foregrounds');
this.foregrounds.forEach((foreground) => {
foreground.isUserInteractionEnabled = true;
});
}
} Any tips would be greatly appreciated! Technically, the view in question, isn't visually covering the view from behind when it's exposed ? Even still, if we were to get this to work, it still won't be ideal UX :( Anyone have luck integrating RadListView with swipe features while using a Slider in the ListView ? Edit2: <!-- Foreground: Feeling Gauge/Sentiment Input -->
<StackLayout class="feeling-gauge-input-container" [isUserInteractionEnabled]="swipeMenuesEnabled">
<StackLayout orientation="horizontal" (pan)="onFeelingHeadPan($event, i)" class="header add-gutter-hack">
<Label [text]="feeling.name | howMuchFeeling"></Label>
<yf-feeling-emoticon [sentiment]="feeling.sentiment" [gauge]="feeling.gauge"></yf-feeling-emoticon>
</StackLayout>
</StackLayout> See Open to suggestions! Edit3: Found a way! (tap)="tapAbsoluteLayout()" Then the function itself: public tapAbsoluteLayout() {
console.log('hi');
if (! this.swipeMenuesEnabled) {
console.log('enable me');
this.swipeMenuesEnabled = true;
} else {
console.log('no change');
}
} So if the menu is open, and swiping is disabled, we can enable it on tap which lets the gesture effect the foreground to swipe close to hide the background menues :) Thank you @NickIliev for pointing out the Edit4: Making the new tap event for the AbsoluteLayout a |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Did you verify this is a real problem by searching Stack Overflow and the other open issues in this repo?
Yes..verified issue on iOS version of {N} only.
Tell us about the problem
I've got an AbsoluteLayout and in it I create a Label element. Then I've got another Label element stacked on top of it - it's wider and transparent background.
Label #1 has a tap event. Label #2 doesn't. I would like all taps on #1 to be called. Nothing for #2.
On iOS, looks like #2 is not passing thru the tap events.
Which platform(s) does your issue occur on?
iOS only.
Please provide the following version numbers that your issue occurs with:
tns --version
to fetch it) 2.4.2iOS platform 2.4.1
Please tell us how to recreate the issue in as much detail as possible.
Create an AbsoluteLayout. Create a label in it and register tap event. Create another label over it.
Now tap on label#1 - events not being called.
Is there code involved? If so, please share the minimal amount of code needed to recreate the problem.
The text was updated successfully, but these errors were encountered: