| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 86be5b6 commit 2625683
10 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -21,6 +21,7 @@ export function loadExamples() { | |||
| 21 | 21 | examples.set("pgrid", "layouts-percent/grid"); | |
| 22 | 22 | examples.set("pstack", "layouts-percent/stack"); | |
| 23 | 23 | examples.set("pwrap", "layouts-percent/wrap"); | |
| 24 | + examples.set("passThroughParent", "layouts/passThroughParent"); | ||
| 24 | 25 | examples.set("stacklayout-6059", "layouts/stacklayout-6059"); | |
| 25 | 26 | ||
| 26 | 27 | return examples; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,19 @@ | |||
| 1 | + export function onOuterWrapLayoutTap() { | ||
| 2 | + console.log("on outer wrap layout tap"); | ||
| 3 | + } | ||
| 4 | + | ||
| 5 | + export function onStackLayoutThrowTap() { | ||
| 6 | + throw new Error("Should not tap layout with IsPassThroughParentEnabled=true"); | ||
| 7 | + } | ||
| 8 | + | ||
| 9 | + export function onUserInteractionDisabledTap() { | ||
| 10 | + throw new Error("Should not tap button with IsUserInteractionEnabled=false"); | ||
| 11 | + } | ||
| 12 | + | ||
| 13 | + export function onDisabledThrowTap() { | ||
| 14 | + throw new Error("Should not tap button with IsEnabled=false"); | ||
| 15 | + } | ||
| 16 | + | ||
| 17 | + export function onTap() { | ||
| 18 | + console.log("on button tap"); | ||
| 19 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,24 @@ | |||
| 1 | + <Page class="page" actionBarHidden="true" xmlns="http://schemas.nativescript.org/tns.xsd"> | ||
| 2 | + | ||
| 3 | + <WrapLayout tap="onOuterWrapLayoutTap" backgroundColor="#bed3f4"> | ||
| 4 | + | ||
| 5 | + <StackLayout tap="onStackLayoutThrowTap" backgroundColor="#f3f9db" height="200" isPassThroughParentEnabled="true"> | ||
| 6 | + <Label text="isPassThroughParentEnabled='true'" isUserInteractionEnabled="false" /> | ||
| 7 | + <Button isUserInteractionEnabled="false" tap="onUserInteractionDisabledThrowTap" text="isUserInteractionEnabled='false'"></Button> | ||
| 8 | + <Button isEnabled="false" tap="onDisabledThrowTap" text="isEnabled='false'"></Button> | ||
| 9 | + <Button tap="onTap" text="TAP"></Button> | ||
| 10 | + </StackLayout> | ||
| 11 | + | ||
| 12 | + <StackLayout tap="onStackLayoutThrowTap" style.margin="20" height="300" width="300" backgroundColor="#f5edf7" isPassThroughParentEnabled="true"> | ||
| 13 | + <Label text="isPassThroughParentEnabled='true'" isUserInteractionEnabled="false" /> | ||
| 14 | + <StackLayout tap="onStackLayoutThrowTap" backgroundColor="#f3f9db" height="200" isPassThroughParentEnabled="true"> | ||
| 15 | + <Label text="isPassThroughParentEnabled='true'" isUserInteractionEnabled="false" /> | ||
| 16 | + <Button isUserInteractionEnabled="false" tap="onUserInteractionDisabledThrowTap" text="isUserInteractionEnabled='false'"></Button> | ||
| 17 | + <Button isEnabled="false" tap="onDisabledThrowTap" text="isEnabled='false'"></Button> | ||
| 18 | + <Button tap="onTap" text="TAP"></Button> | ||
| 19 | + </StackLayout> | ||
| 20 | + </StackLayout> | ||
| 21 | + | ||
| 22 | + </WrapLayout> | ||
| 23 | + | ||
| 24 | + </Page> | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1021,4 +1021,4 @@ export const isEnabledProperty = new Property<ViewCommon, boolean>({ | |||
| 1021 | 1021 | isEnabledProperty.register(ViewCommon); | |
| 1022 | 1022 | ||
| 1023 | 1023 | export const isUserInteractionEnabledProperty = new Property<ViewCommon, boolean>({ name: "isUserInteractionEnabled", defaultValue: true, valueConverter: booleanConverter }); | |
| 1024 | - isUserInteractionEnabledProperty.register(ViewCommon); | ||
| 1024 | + isUserInteractionEnabledProperty.register(ViewCommon); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -357,15 +357,20 @@ export class View extends ViewCommon { | |||
| 357 | 357 | } | |
| 358 | 358 | ||
| 359 | 359 | private setOnTouchListener() { | |
| 360 | - if (this.nativeViewProtected && this.hasGestureObservers()) { | ||
| 361 | - this.touchListenerIsSet = true; | ||
| 362 | - if (this.nativeViewProtected.setClickable) { | ||
| 363 | - this.nativeViewProtected.setClickable(true); | ||
| 364 | - } | ||
| 360 | + if (!this.nativeViewProtected || !this.hasGestureObservers()) { | ||
| 361 | + return; | ||
| 362 | + } | ||
| 363 | + | ||
| 364 | + // do not set noop listener that handles the event (disabled listener) if IsUserInteractionEnabled is | ||
| 365 | + // false as we might need the ability for the event to pass through to a parent view | ||
| 366 | + initializeTouchListener(); | ||
| 367 | + this.touchListener = this.touchListener || new TouchListener(this); | ||
| 368 | + this.nativeViewProtected.setOnTouchListener(this.touchListener); | ||
| 369 | + | ||
| 370 | + this.touchListenerIsSet = true; | ||
| 365 | 371 | ||
| 366 | - initializeTouchListener(); | ||
| 367 | - this.touchListener = this.touchListener || new TouchListener(this); | ||
| 368 | - this.nativeViewProtected.setOnTouchListener(this.touchListener); | ||
| 372 | + if (this.nativeViewProtected.setClickable) { | ||
| 373 | + this.nativeViewProtected.setClickable(this.isUserInteractionEnabled); | ||
| 369 | 374 | } | |
| 370 | 375 | } | |
| 371 | 376 | ||
@@ -605,15 +610,8 @@ export class View extends ViewCommon { | |||
| 605 | 610 | } | |
| 606 | 611 | ||
| 607 | 612 | [isUserInteractionEnabledProperty.setNative](value: boolean) { | |
| 608 | - if (!value) { | ||
| 609 | - initializeDisabledListener(); | ||
| 610 | - // User interaction is disabled -- we stop it and we do not care whether someone wants to listen for gestures. | ||
| 611 | - this.nativeViewProtected.setOnTouchListener(disableUserInteractionListener); | ||
| 612 | - } else { | ||
| 613 | - this.setOnTouchListener(); | ||
| 614 | - if (!this.touchListenerIsSet) { | ||
| 615 | - this.nativeViewProtected.setOnTouchListener(null); | ||
| 616 | - } | ||
| 613 | + if (this.nativeViewProtected.setClickable) { | ||
| 614 | + this.nativeViewProtected.setClickable(value); | ||
| 617 | 615 | } | |
| 618 | 616 | } | |
| 619 | 617 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,4 @@ | |||
| 1 | - // Definitions. | ||
| 1 | + // Definitions. | ||
| 2 | 2 | import { Point, View as ViewDefinition, dip } from "."; | |
| 3 | 3 | import { ViewBase } from "../view-base"; | |
| 4 | 4 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -106,6 +106,7 @@ export class LayoutBaseCommon extends CustomLayoutView implements LayoutBaseDefi | |||
| 106 | 106 | } | |
| 107 | 107 | ||
| 108 | 108 | public clipToBounds: boolean; | |
| 109 | + public isPassThroughParentEnabled: boolean; | ||
| 109 | 110 | ||
| 110 | 111 | public _childIndexToNativeChildIndex(index?: number): number { | |
| 111 | 112 | if (index === undefined) { | |
@@ -151,3 +152,6 @@ export class LayoutBaseCommon extends CustomLayoutView implements LayoutBaseDefi | |||
| 151 | 152 | ||
| 152 | 153 | export const clipToBoundsProperty = new Property<LayoutBaseCommon, boolean>({ name: "clipToBounds", defaultValue: true, valueConverter: booleanConverter }); | |
| 153 | 154 | clipToBoundsProperty.register(LayoutBaseCommon); | |
| 155 | + | ||
| 156 | + export const isPassThroughParentEnabledProperty = new Property<LayoutBaseCommon, boolean>({ name: "isPassThroughParentEnabled", defaultValue: false, valueConverter: booleanConverter }); | ||
| 157 | + isPassThroughParentEnabledProperty.register(LayoutBaseCommon); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,5 @@ | |||
| 1 | 1 | import { | |
| 2 | - LayoutBaseCommon, clipToBoundsProperty, | ||
| 2 | + LayoutBaseCommon, clipToBoundsProperty, isPassThroughParentEnabledProperty, | ||
| 3 | 3 | paddingLeftProperty, paddingTopProperty, paddingRightProperty, paddingBottomProperty, Length | |
| 4 | 4 | } from "./layout-base-common"; | |
| 5 | 5 | ||
@@ -25,6 +25,10 @@ export class LayoutBase extends LayoutBaseCommon { | |||
| 25 | 25 | console.warn(`clipToBounds with value false is not supported on Android. You can use this.android.getParent().setClipChildren(false) as an alternative`); | |
| 26 | 26 | } | |
| 27 | 27 | ||
| 28 | + [isPassThroughParentEnabledProperty.setNative](value: boolean) { | ||
| 29 | + (<any>this.nativeViewProtected).setPassThroughParent(value); | ||
| 30 | + } | ||
| 31 | + | ||
| 28 | 32 | [paddingTopProperty.getDefault](): Length { | |
| 29 | 33 | return { value: this._defaultPaddingTop, unit: "px" }; | |
| 30 | 34 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -96,6 +96,14 @@ export class LayoutBase extends CustomLayoutView { | |||
| 96 | 96 | * Gets or sets a value indicating whether to clip the content of this layout. | |
| 97 | 97 | */ | |
| 98 | 98 | clipToBounds: boolean; | |
| 99 | + | ||
| 100 | + /** | ||
| 101 | + * Gets or sets a value indicating whether touch event should pass through to a parent view of the | ||
| 102 | + * layout container in case an interactive child view did not handle it. | ||
| 103 | + * Default value of this property is false. This does not affect the appearance of the view. | ||
| 104 | + */ | ||
| 105 | + isPassThroughParentEnabled: boolean; | ||
| 99 | 106 | } | |
| 100 | 107 | ||
| 101 | 108 | export const clipToBoundsProperty: Property<LayoutBase, boolean>; | |
| 109 | + export const isPassThroughParentEnabledProperty: Property<LayoutBase, boolean>; | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,6 @@ | |||
| 1 | - import { LayoutBaseCommon, clipToBoundsProperty, View } from "./layout-base-common"; | ||
| 1 | + import { | ||
| 2 | + LayoutBaseCommon, clipToBoundsProperty, isPassThroughParentEnabledProperty, View | ||
| 3 | + } from "./layout-base-common"; | ||
| 2 | 4 | ||
| 3 | 5 | export * from "./layout-base-common"; | |
| 4 | 6 | ||
@@ -34,4 +36,8 @@ export class LayoutBase extends LayoutBaseCommon { | |||
| 34 | 36 | [clipToBoundsProperty.setNative](value: boolean) { | |
| 35 | 37 | this._setNativeClipToBounds(); | |
| 36 | 38 | } | |
| 39 | + | ||
| 40 | + [isPassThroughParentEnabledProperty.setNative](value: boolean) { | ||
| 41 | + (<any>this.nativeViewProtected).setPassThroughParent(value); | ||
| 42 | + } | ||
| 37 | 43 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments