Skip to content
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

Dont respond to any clicks in target #346

Closed
Tristannos opened this issue Feb 28, 2023 · 19 comments · Fixed by #351
Closed

Dont respond to any clicks in target #346

Tristannos opened this issue Feb 28, 2023 · 19 comments · Fixed by #351

Comments

@Tristannos
Copy link

When i am showcasing things i don't want them to be able to click on the item in the target.

Make the target absorb the pointer when the current showcase is selected

luccasclezar added a commit to luccasclezar/flutter_showcaseview that referenced this issue Feb 28, 2023
@luccasclezar
Copy link

Hey @Tristannos, if you want to test my fix you can use this in your pubspec:

  showcaseview:
    git: https://github.com/luccasclezar/flutter_showcaseview.git

Or fork my repo and change the url to your fork.

@ujas-m-simformsolutions
Copy link
Contributor

@Tristannos you can do this by setting disableDefaultTargetGestures parameter to true.

Showcase(
  disableDefaultTargetGestures: true,
...
),

@ujas-m-simformsolutions
Copy link
Contributor

@luccasclezar your PR is related to overlay layout so it won't have any effect on gestures.

@luccasclezar
Copy link

@ujas-m-simformsolutions The overlay that prevents gestures from passing through the barrier is misplaced. My PR fixes the overlay's position so that it can correctly intercept gestures. 🙂

@vatsaltanna
Copy link
Collaborator

vatsaltanna commented Mar 6, 2023

Hi @Tristannos , You can use below code to disable gestures on target widget.

disposeOnTap: false,
onTargetClick: () {},

PS: Closing this issue for now, feel free to reopen this issue if this solutions doesn't work for you.

@luis901101
Copy link

Hi @Tristannos , You can use below code to disable gestures on target widget.

disposeOnTap: false,
onTargetClick: () {},

PS: Closing this issue for now, feel free to reopen this issue if this solutions doesn't work for you.

In my case I have a FAB as target widget and if I tap on it, then it's onPressed function get's called back.

@vatsaltanna
Copy link
Collaborator

Hi @Tristannos , You can use below code to disable gestures on target widget.

disposeOnTap: false,
onTargetClick: () {},

PS: Closing this issue for now, feel free to reopen this issue if this solutions doesn't work for you.

In my case I have a FAB as target widget and if I tap on it, then it's onPressed function get's called back.

have you tried the configuration I have shared?

@vatsaltanna
Copy link
Collaborator

Don't forget to remove disableDefaultTargetGestures: true, from the code only use below code.

disposeOnTap: false,
onTargetClick: () {},

@luis901101
Copy link

Yep, since the first time,

Don't forget to remove disableDefaultTargetGestures: true, from the code only use below code.

disposeOnTap: false,
onTargetClick: () {},

Yess, this was my initial configuration, I just checked each property an it's documentation and this one you propose is the right but it doesn't work as expected in my case. I have ShowCaseWidget as parent of Scaffold and Showcase as child of scafold's floatingActionButton: property.

@vatsaltanna
Copy link
Collaborator

Yup that is fine, I tried with floating action button in example with the same config I shared with you and it works fine it ignores the omPressed event of FAB. Can you please share a reproducible code snippet of the issue you are facing ?

@luis901101
Copy link

flutter doctor -v

[✓] Flutter (Channel stable, 3.7.4, on macOS 13.0 22A380 darwin-arm64, locale en-US)
    • Flutter version 3.7.4 on channel stable at /Users/user/fvm/versions/3.7.4
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision b4bce91dd0 (2 weeks ago), 2023-02-21 09:50:50 +0800
    • Engine revision 248290d6d5
    • Dart version 2.19.2
    • DevTools version 2.20.1

Checking Android licenses is taking an unexpectedly long time...[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1)
    • Android SDK at /Users/user/Android/SDK
    • Platform android-33, build-tools 33.0.1
    • ANDROID_HOME = /Users/user/Android/SDK
    • Java binary at: /Users/user/.sdkman/candidates/java/current/bin/java
    • Java version OpenJDK Runtime Environment Zulu11.56+19-CA (build 11.0.15+10-LTS)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14C18
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[!] Android Studio (version 2022.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    ✗ Unable to find bundled Java version.
    • Try updating or re-installing Android Studio.

Reproducible code snippet:

import 'package:flutter/material.dart';
import 'package:showcaseview/showcaseview.dart';

class TestShowcase extends StatefulWidget {
  static Future start(BuildContext context) => Navigator.push(
      context, MaterialPageRoute(builder: (context) => TestShowcase()));

  @override
  State createState() => _TestShowcaseState();
}

class _TestShowcaseState extends State<TestShowcase> {
  final fabKey = GlobalKey();

  @override
  Widget build(BuildContext context) {
    return ShowCaseWidget(
      builder: Builder(
        builder: (context) {
          return Scaffold(
            floatingActionButton: Showcase(
              key: fabKey,
              disposeOnTap: false,
              onTargetClick: () {
                print('onTargetClick from Showcase');
              },
              targetShapeBorder: const CircleBorder(),
              targetPadding: const EdgeInsets.all(4),
              description: 'Fab onTargetClick test',
              child: FloatingActionButton(
                shape: const CircleBorder(),
                onPressed: () {
                  print('onPressed from FAB');
                },
              ),
            ),
            body: Center(
              child: ElevatedButton(
                child: const Text('Start ShowCase'),
                onPressed: () {
                  ShowCaseWidget.of(context).startShowCase([fabKey]);
                },
              ),
            ),
          );
        },
      ),
    );
  }
}

@vatsaltanna vatsaltanna reopened this Mar 7, 2023
@vatsaltanna
Copy link
Collaborator

This issue is reproduciable. @luis901101 Thanks for the code snippet. was this working as expected in previous flutter version ?

vatsaltanna added a commit that referenced this issue Mar 7, 2023
#348 showcaseview after upgrade to flutter 3.7.1 not disable target click
@luis901101
Copy link

This issue is reproduciable. @luis901101 Thanks for the code snippet. was this working as expected in previous flutter version ?

Not sure, I just started using it in a new project with this 3.7.4 flutter version

@dshpindler
Copy link

I'm having the same issue since upgrading to flutter 3.7.x.
the pointer was absorbed properly before
(if you tap very close to the edge of the showcase child, you will get desired behavior)

@vatsaltanna
Copy link
Collaborator

we will release the new version as soon as possible. meanwhile you can use the previoud version of showcaseview showcaseview: ^2.0.0+1.

vatsaltanna added a commit that referenced this issue Mar 10, 2023
#348 showcaseview after upgrade to flutter 3.7.1 not disable target click
vatsaltanna added a commit that referenced this issue Mar 10, 2023
#348 showcaseview after upgrade to flutter 3.7.1 not disable target click
@vatsaltanna vatsaltanna linked a pull request Mar 10, 2023 that will close this issue
7 tasks
@vatsaltanna
Copy link
Collaborator

This issue has been fixed in latest release showcaseview: ^2.0.2. please use below code to avoid gestures on target widget.

disposeOnTap: false,
onTargetClick: () {},

@AlmutawakelSukaina
Copy link

@Tristannos does your issue resolved with new version showcaseview: ^2.0.2?!

@vatsaltanna
Copy link
Collaborator

Hi @AlmutawakelSukaina , please remove flag disableDefaultTargetGestures: true, and add below code.

disposeOnTap: false,
onTargetClick: () {},

Note: disableDefaultTargetGestures: true allows external gesture to work so if you will remove it then default value will be false

@AlmutawakelSukaina
Copy link

@vatsaltanna Thank you that's work for me

satria-wardana added a commit to satria-wardana/flutter_showcaseview that referenced this issue Sep 7, 2023
* master: (55 commits)
  📝 Update CHANGELOG.md file for version 2.0.3. (SimformSolutionsPvtLtd#368)
  feat: ✨ Add callback when barrier has been clicked (SimformSolutionsPvtLtd#359)
  fixed-child-constructor-invocation (SimformSolutionsPvtLtd#361)
  ✨ (SimformSolutionsPvtLtd#148) Add feasibility to add `textDirection` of `title` and `description`. (SimformSolutionsPvtLtd#356)
  fix: 🐛 SimformSolutionsPvtLtd#346 Don't respond to any clicks in target & (SimformSolutionsPvtLtd#351)
  fix: 🐛 Flutter inspector makes screen grey (SimformSolutionsPvtLtd#353)
  🔖 version bump 2.0.0+1 to 2.0.1 (SimformSolutionsPvtLtd#341)
  fix: 🐛 Take in account view insets (such as keyboard) (SimformSolutionsPvtLtd#288)
  Miscellaneous changes
  Add missing copyright notice in enum.dart
  feat: ✨ Add padding to title and description
  fix: 🐛 PR title validation workflow issue (SimformSolutionsPvtLtd#322)
  feat: ✨ Provide Manual option for vertical position of tooltip (SimformSolutionsPvtLtd#306)
  feat: ✨ Enable/disable showcase globally. (SimformSolutionsPvtLtd#319)
  ✨ add mac support in example. (SimformSolutionsPvtLtd#197)
  Fix: 🔨 Remove title validation workflow (SimformSolutionsPvtLtd#321)
  chore: 👷workflow for PR title validation (SimformSolutionsPvtLtd#286)
  release: 🔖 version bump 2.0.0 to 2.0.0+1 (SimformSolutionsPvtLtd#302)
  release: 🔖 version bump 1.1.8 to 2.0.0 (SimformSolutionsPvtLtd#301)
  fix: 🐛 logic update in `tooltip_widget.dart` (SimformSolutionsPvtLtd#300)
  ...

# Conflicts:
#	example/ios/Flutter/AppFrameworkInfo.plist
#	example/ios/Runner.xcodeproj/project.pbxproj
#	example/lib/main.dart
#	lib/src/showcase.dart
#	lib/src/showcase_widget.dart
#	lib/src/tooltip_widget.dart
LocLt-Mobile pushed a commit to guide-inc-org/guide-flutter_showcaseview that referenced this issue Oct 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
7 participants