fix(button): ios let the gesture observer handles tap events

in some weird cases like i some UICollectionView layouts the UIControlEvents.TouchUpInside is failing
This commit is contained in:
Martin Guillon
2021-03-18 14:00:36 +01:00
parent 56a3f9bd3c
commit a2d06a9efe
19 changed files with 62 additions and 59 deletions

View File

@ -51,7 +51,7 @@ export function createPage() {
//page.content = GridLayout;
page.content = StackLayout;
var x = 1;
btn1.on(button.Button.tapEvent, function () {
btn1.on(button.tapEvent, function () {
x++;
var gravity;
//btn1.android.setLayoutParams(new android.view.ViewGroup.LayoutParams(android.view.ViewGroup.LayoutParams.FILL_PARENT, android.view.ViewGroup.LayoutParams.FILL_PARENT));

View File

@ -13,7 +13,7 @@ export function createPage() {
var vAligns: VerticalAlignment[] = ['stretch', 'top', 'middle', 'bottom'];
//var hAligns = ["stretch", "left", "center", "right"];
var count = 0;
btn.on(buttons.Button.tapEvent, function () {
btn.on(buttons.tapEvent, function () {
//page.css = "button { vertical-align:" + vAligns[(count++) % 4] + " }";
btn.verticalAlignment = vAligns[count++ % 4];
});

View File

@ -41,7 +41,7 @@ export function createPage() {
var counter = 0;
var btn = new btns.Button();
btn.text = 'tap';
btn.on(btns.Button.tapEvent, function () {
btn.on(btns.tapEvent, function () {
btn.text = 'hi: ' + counter++;
});
btn.isEnabled = false;
@ -52,7 +52,7 @@ export function createPage() {
var info = new btns.Button();
info.text = 'info';
info.className = 'info';
info.on(btns.Button.tapEvent, function () {
info.on(btns.tapEvent, function () {
info.text = 'hi: ' + counter++;
btn.isEnabled = true;
});

View File

@ -41,7 +41,7 @@ export function createPage() {
var count = 0;
var control = new btns.Button();
control.text = 'test control';
control.on(btns.Button.tapEvent, (data) => {
control.on(btns.tapEvent, (data) => {
control.text = 'count: ' + count++;
});
grid.addChild(control);

View File

@ -6,7 +6,7 @@ import { Frame } from '@nativescript/core/ui/frame';
import { Page } from '@nativescript/core/ui/page';
import { ListView, ItemEventData } from '@nativescript/core/ui/list-view';
import { BottomNavigation, TabContentItem, TabStrip, TabStripItem } from '@nativescript/core';
import { Button } from '@nativescript/core/ui/button';
import { Button , tapEvent} from '@nativescript/core/ui/button';
var ASYNC = 2;
@ -55,7 +55,7 @@ function _createListView(): ListView {
var button = <Button>args.view;
if (!button) {
button = new Button();
button.on(Button.tapEvent, _clickHandlerFactory(args.index));
button.on(tapEvent, _clickHandlerFactory(args.index));
args.view = button;
}

View File

@ -3,6 +3,7 @@ import * as helper from '../../ui-helper';
import { View, EventData, Button, Observable, Color, Page, FormattedString } from '@nativescript/core';
import * as buttonTestsNative from './button-tests-native';
import * as spanModule from '@nativescript/core/text/span';
import { tapEvent} from '@nativescript/core/ui/button';
// >> button-require-others
import { BindingOptions } from '@nativescript/core/ui/core/bindable';
@ -100,7 +101,7 @@ var _testOnClick = function (views: Array<View>) {
var actualValue = false;
// >> button-tap
button.on(Button.tapEvent, function (args: EventData) {
button.on(tapEvent, function (args: EventData) {
// Do something
// >> (hide)
actualValue = true;

View File

@ -13,7 +13,7 @@ export class MyControl extends stackLayoutModule.StackLayout {
lbl.id = 'my-test-label';
var btn = new button.Button();
btn.text = 'Tap me!';
btn.on(button.Button.tapEvent, (args: EventData) => {
btn.on(button.tapEvent, (args: EventData) => {
lbl.text = 'Tap ' + counter++;
});

View File

@ -7,7 +7,7 @@ import { Frame } from '@nativescript/core/ui/frame';
import { Page } from '@nativescript/core/ui/page';
import { ListView, ItemEventData } from '@nativescript/core/ui/list-view';
import { TabView, TabViewItem } from '@nativescript/core/ui/tab-view';
import { Button } from '@nativescript/core/ui/button';
import { Button, tapEvent} from '@nativescript/core/ui/button';
var ASYNC = 2;
@ -44,7 +44,7 @@ function _createListView(): ListView {
var button = <Button>args.view;
if (!button) {
button = new Button();
button.on(Button.tapEvent, _clickHandlerFactory(args.index));
button.on(tapEvent, _clickHandlerFactory(args.index));
args.view = button;
}

View File

@ -1,4 +1,5 @@
import { StackLayout, Label, Button, EventData } from '@nativescript/core';
import { tapEvent } from '@nativescript/core/ui/button';
export class MyControl extends StackLayout {
constructor() {
@ -9,7 +10,7 @@ export class MyControl extends StackLayout {
var lbl = new Label();
var btn = new Button();
btn.text = 'Tap me!';
btn.on(Button.tapEvent, (args: EventData) => {
btn.on(tapEvent, (args: EventData) => {
lbl.text = 'Tap ' + counter++;
});

View File

@ -28,7 +28,7 @@ export function createPage() {
//buttonTwoWay.automationText = "buttonTwoWay";
buttonSetText.text = 'SetText';
buttonSetText.on(buttonModule.Button.tapEvent, function () {
buttonSetText.on(buttonModule.tapEvent, function () {
targetOneWay.text = 'Test';
targetTwoWay.text = 'Test';
});
@ -47,7 +47,7 @@ export function createPage() {
buttonOneWay.on(buttonModule.Button.loadedEvent, function () {
buttonOneWay.text = sourceOneWay.get('textSource');
});
buttonOneWay.on(buttonModule.Button.tapEvent, function () {
buttonOneWay.on(buttonModule.tapEvent, function () {
buttonOneWay.text = sourceOneWay.get('textSource');
});
@ -67,7 +67,7 @@ export function createPage() {
buttonTwoWay.on(buttonModule.Button.loadedEvent, function () {
buttonTwoWay.text = sourceTwoWay.get('textSource');
});
buttonTwoWay.on(buttonModule.Button.tapEvent, function () {
buttonTwoWay.on(buttonModule.tapEvent, function () {
buttonTwoWay.text = sourceTwoWay.get('textSource');
});

View File

@ -16,7 +16,7 @@ export function stack0Loaded(args: observable.EventData) {
target.bind(bindingOptions, source);
source.set('textSource', 'Text');
button.on(buttonModule.Button.tapEvent, function () {
button.on(buttonModule.tapEvent, function () {
button.text = source.get('textSource');
});
}

View File

@ -7,7 +7,7 @@ export function createPage() {
var btn = new button.Button();
btn.text = 'Alert';
btn.on(button.Button.tapEvent, function () {
btn.on(button.tapEvent, function () {
alert('Alert is global');
});

View File

@ -1,5 +1,5 @@
import { Observable } from '@nativescript/core/data/observable';
import { Button } from '@nativescript/core/ui/button';
import { Button, tapEvent } from '@nativescript/core/ui/button';
import { Color } from '@nativescript/core/color';
import { WrapLayout } from '@nativescript/core/ui/layouts/wrap-layout';
import { alert } from '@nativescript/core/ui/dialogs';
@ -65,7 +65,7 @@ export class TestPageMainViewModel extends Observable {
btn.style.backgroundColor = new Color(this._colors[count++ % 3]);
btn.style.borderRadius = 5;
btn.on(
Button.tapEvent,
tapEvent,
function (eventData) {
let text = btn.text;
this.loadExample(text);