Nativescript - view tap event pass-thru in iOS? - nativescript

I've got a Label (#1) and on top of it (and wider and transparent background) I have another label (#2).
I've got a tap event callback set for label #1.
In iOS, it seems like the top label is not passing the tap to the bottom Label - even though there's no tap event set for Label #2.
I set label2.isUserInteractionEnabled to false but no help.
On Android, the pass-thru works fine.
Help appreciated.

Setting label2.isUserInteractionEnabled to false on the top Label element works as advertised.

Related

Slider inside Horizontal scroll view issue in IOS

My layout has severalsliders in a scroll view which scrolls horizontally. The issue is when I try to drag the slider thumb it is not moving instead the scroll view itself scrolls horizontally. How to fix this? (In Swift)
Swift 3 Solution
I was facing a similar issue and fixed it by setting
scrollView.delaysContentTouches = false
Explanation
According to Apple Docs
If the value of this property (delaysContentTouches) is true, the scroll view delays handling the touch-down gesture until it can determine if scrolling is the intent. If the value is false , the scroll view immediately calls touchesShouldBegin(_:with:in:)
. The default value is true.
As the word suggests it delays the content touch (i.e lowers the priority of subview's action) leading to irresponsive subview content updation during scrolling.
When this property is set to false it gives priority to the subview's action (by immediately calling touchesShouldBegin(_:with:in:)) leading to responsive subview content updation.
Maybe you call UISlider "Lazy var". Let's change it to "Let"

UIScrollView on tvOS

The question is very simple, how to enable scroll and zoom inside a UIScrollView in tvOS?
I tried the same initializer code from iOS and returned the scrollview for the focusedView var, but nothing happens when i touch the remote.
Also, i tried to add another custom UIPanGestureRecognizer to the scrollview and actually it works, but i don't want to handle the pan with custom code, just use the same pan behavior like iOS.
Let me know, thanks.
You can configure the scroll view's built-in pan gesture to recognize touches on the Siri Remote. It doesn't do that automatically, because normally scroll views on tvOS aren't scrolled directly by touches: they're scrolled automatically as focus moves between views within the scroll view.
If you really want the scroll view to move directly from touches, you'll need to add UITouchTypeIndirect to the allowedTouchTypes of the scroll view's panGestureRecognizer:
scrollView.panGestureRecognizer.allowedTouchTypes = #[ #(UITouchTypeIndirect) ];
You'll also need to make sure that either the scroll view itself is the focused view, or is a parent of the focused view, since all touches from the remote will start at the center of the focused view: you need to make sure the scroll view is getting hit-tested for the events to work.
Zooming won't work, because the Siri Remote can only recognize one touch at a time, so you can't do a pinch gesture on it.
Swift 4 version (from here: https://stackoverflow.com/a/41000183/945247)
scrollView.panGestureRecognizer.allowedTouchTypes = [NSNumber(value:UITouchType.indirect.rawValue)]

How can I get a two-row toolbar like in Mail.app and Xcode?

I'm trying to add a "second row" after my NSToolbar in my app, that remains part of the title bar. As an example, Mail has a thin gray divider line below the NSToolbar with some extras items below that. Very specifically, when the window is put into fullscreen mode, that second "row" stays attached to the title bar as it slides down under the system menu bar. Xcode has a similar story.
I tried setting my NSWindow to textured and placing my second row controls directly in the content view of the window. While this mostly looks correct in windowed mode, those controls of course won't appear attached to the toolbar when it slides down in fullscreen mode. So how can I achieve the same behavior that Mail and Xcode do? I've looked at a lot of toolbar customization code but none of them really cover this specific case.
fullScreenAccessoryView is deprecated in macOS 10.10
In order to do this in recent versions of macOS, use the addTitlebarAccessoryViewController method on your NSWindow and pass in a subclass of NSTitlebarAccessoryViewController.
For example:
NSTitlebarAccessoryViewController *accessoryViewController = [[NSStoryboard storyboardWithName:#"Main" bundle:nil] instantiateControllerWithIdentifier:#"AccessoryViewController"];
[self.mainWindowController.window addTitlebarAccessoryViewController:accessoryViewController];
What I needed to do was call [NSToolbar setFullScreenAccessoryView:] on the view below my toolbar. This results in the behavior I was aiming for. See the NSToolbar documentation for this method.
First one is normal toolbar. For second toolbar you can create a separate view of your desired height and add it in the main landing-window.

Using a round rect button as a badge with a counter

I'm using a view based NSOutlineView with two different views (both views are custom subclasses of NSTableCellView). In the top level view I display a badge with a counter. The counter indicates the number of entries on the lower level. The counter is implemented as a rounded rect NSButton, following Apple's SidebarDemo project.
As you can see from the images the behaviour of the button upon selection of the cell is not the behaviour you would expect. My button turns black, while in Apple's sample it turns white. I've tracked down the method that sets this particular behaviour for a button to the setHighlightsBy method:
[[self.button cell] setHighlightsBy: 0];
I use the above in the awakeFromNib method of the custom cell class. In the same awakeFromNib I also set the button's bezel:
[[self.button cell] setBezelStyle: NSInlineBezelStyle];
The bezel style works just fine, but the highlighting seems to be ignored.
Further information I can give: The outline view uses bindings to gets its contents, its highlight mode is set to "Source List".
Why is my highlighting being ignored?
Is your button set up in IB (like in the demo project)? If so, do you have the "enable" box checked in the control section of the attributes inspector? I got the behavior you're seeing if I unchecked that box.
I found the cause of the described behaviour, thanks to the suggestion made by #rdelmar in his answer. The button is bound to the Cell View using the "Argument" binding inspector.
One of the settings there is "Conditionally sets enabled", which was enabled and apparently causes auto-disabling of my button. Once you disable this setting, the problem disappears.

Slider stops working after first use

I have a Slider control inside a ScrollView (there are other elements, but those are the pertinent ones). When you "let go" of the slider (OnMouseLeftButtonUp - also works for taps), a network command is sent and the slider is momentarily greyed out. After the slider becomes available again, when I try to drag it, it will not work, and the "let go" event doesn't fire.
I have already tried setting e.Handled to True/False but it seems to do nothing. What would cause a Slider to stop working after it's used one time? -Or- Is there a better event I should be using to detect when the value changes on the slider after the user has let go of it?
Found the problem. You can't use a Toggle Switch (from the Silverlight SDK) with a slider because one takes exclusive control of a GestureListener.
Here's the fix I used, it worked perfectly (near the bottom):
http://social.msdn.microsoft.com/Forums/en-US/wpdevelop/thread/ba8bfef3-44a2-4e63-bded-97013e38772e/
You just have to wrap your sliders in a <Canvas> element and insert some event handlers.

Resources