I'm working on an app using Angular 2+ and Nativescript 5. In a normal button I listen to "taps" with the tap event:
<Button text="Tap me" (tap)="onTap($event)"></Button>
But the tap event triggers after the finger releases the button.
Now I want to listen to the "ButtonDown" event, when the finger touches the button. But I can't find that event on the docs!
Is there any workaround that works in this case?
You may have to listen for the touch event and make sure the action is down.
Related
I'm trying to implement a function that will be called when user press back button.
Working exactly how i expect in UWP, but the issue is with android.
In android I got two back button,
One at top Navigation (Let's call it navbackbutton ), and other we get at bottom, the three android button "background apps,Home and back button(android backbutton),
Android back button is firing onBackpressed override method but navbackbutton is not, it is just taking me to the previous page.
I dont understand why it is happening and how to fix it.
Page.OnBackButtonPressed is only triggered with the hardware back button on Android .
You can override OnOptionsItemSelected within MainActivity to hook the navigation back button event , refer to here .
Another way is that customize NavigationPage.TitleView(a layout with a back button and title label) to replace the default navigation bar and then you can get the back button event .
I have a map with events associated with "click" that get fired when using mouse but if I use the touch screen they don't
example
map.on("click", () => console.log("blarg")
blarg gets logged if I click on the map with a mouse but does not if I touch the map with a touchscreen. This is on a windows computer and in an electron app (latest version of mapboxgl-js)
There are already similar questions answered on Stack Overflow:
Would onClick event work on touch on touch-screen devices?
document .click function for touch device
You can use touchstart and touchend events that are similar to mousedown and mouseup or use jQuery to detect taps.
Supporting both TouchEvent and MouseEvent - MDN
I've got the following ActionBar definition
<ActionBar class="action-bar" title="Settings">
<NavigationButton text="Go Back" android.systemIcon="ic_menu_back" tap="onBackTap"/>
</ActionBar>
The Android version does get called.
In the iOS version - the onBackTap method is never called.
Also it seems in iOS version, even if the NavigationButton entry is not there, {N} inserts one automatically.
UPDATE:
Indeed, it appears that the NavigationButton in iOS can only be used to navigate back and can not be overridden with tap action. Reference from the NativeScript documentation
In iOS, the back button is used explicitly for navigation. It
navigates to the previous page and you cannot handle the tap event to
override this behaviour.
As for the appearing NavigationButton for iOS - it is by design just as in native iOS app. If you do not want to have back navigation you can force it with
clearHistory: true
Uncomment this line in the test application and delete the navigationButton from the sub-page and when navigation from main-page to sub-page the NavButton won't appear.
So as #nick verified, on iOS version of {N} one cannot get the tap event of the Navigation button. I understand why {N} has to add the BACK button automatically if the navigation button is not there (because iPhones don't have a physical BACK button), but not calling an existing tap event is, IMHO, adding unnecessary differences in the framework. Here's the proposed logic for iOS.
if NavigationButton present then
if tap event handler set by user then
use it
else
auto-gen a tap event handler
else
auto-gen a back-button and a tap event handler
Anyway here's how I'm getting around this issue for my app.
<NavigationButton visibility="collapse"/>
<ActionItem ios.position="left" text="< Back" tap="onBack"/>
This gets the behavior I expect and is cross-platform compatible with the Android version.
How do I re-establish the clicked event of a Xamarin Forms button?
The button was made invisible and it's footprint covered by a popup listview. The listview was subsequently removed, but the button does not respond. Other buttons on the page do.
This only happens on the iOS version of the page.
Can anybody give me more details on this?
I know that tap is coming from gestures, but I'd like to know more on WP7 events model.
For instance how following scenarions work:
stackpanel with tap event and checkbox inside which handles click
container with tap and any framework element also with tap, etc.
Which events have more priority and if is it possible to mask events?
What kind of event bubbling is used here from top to bottom or vice-versa?
If you're using WP7.1 SDK the easiest thing to make things consistent would be to use the Tap event everywhere (it's available on all UIElement derived controls). Tap events are bubbled up from the lowest control in the visual tree until a handler is found.
Then you don't need to worry about if/when Click and Tap will clash.