Why does my AutoSuggestBox open at random? - xaml

I have a UWP/xaml application. I use AutoSuggestBox on many screens, often several of them on a screen.
I have a problem where the suggestions for one or more of these controls pop open at unwanted times, usually when a screen first renders. Nobody has clicked or tapped on the control. Furthermore, it appears to be in a weird state in which the suggestion list seems to be floating above the window containing the control, often extending outside of that window.
The problem is not consistent. I've identified a few paths that make it happen frequently, but there doesn't seem to be any explanation as to why it is happening sometimes on some controls but not others.
Frank

Related

WinRT: prevent ListView from scrolling when partially visible item is tapped

I have an app that shows entries in a ListView. Some entries are long, some are short. When user clicks (or taps) on a entry, app shows entry page. Pretty standard.
But there's one thing that bothers me a lot. When entry is long (and can't be fully displayed, just because phone screen is not big enough) and user taps at it, ListView automatically scrolls into the end of the entry. This is really annoying and I want it to stop.
I found exactly the same issue, but for WPF. RequestBringIntoView is not available in Windows Runtime.
When someone clicks on an item in the listView disable the listView to lock it but as Hassan has said it is not the best solution but it can save you time.

Move focus to other UIButton

I am working on a small game for Apple TV, and one thing I can't get to work is moving the focus from one button to the other (programmatically), or temporarily remove focus from any object (buttons) as the game is doing stuff.
I've seen the guide about objects and focus, but is there really no way to programmatically move the focus to an other part of the screen as the input is needed there (instead of letting the user move all the way across the screen)?
There will always be a view that has focus. It's not possible to not have a focused view.
You could temporarily change the focused appearance of an item, so it doesn't appear to have focus, but that would likely be be confusing for the user, or conflict with Human Interface Guidelines.
There's no explicit way to programmatically move focus from one control to another, per the App Programming Guide for tvOS:
The Focus Engine Controls Focus
Only the focus engine can explicitly update focus, meaning there is no API for directly setting the focused view or moving focus in a certain direction. ...
The focus engine controls focus to make sure that it does not move around the screen unexpectedly, and that it behaves similarly across different applications.
Answers to other questions have suggested that you could "game" the system by overriding preferredFocusedView, conditionally setting it to the desired control to move to, then requesting a focus update. Such an approach would likely be fragile.

Controlling NSSegmentedControl with the keyboard

I have a form in my Cocoa app that contains an NSSegmentedControl that I want to be controllable via the keyboard. It seems that NSSegmentedControl is very reluctant to become the first responder, however.
Setting the initial first responder of the window to the segmented control does nothing -- it will not have keyboard focus when the window is first loaded. It does receive focus if I manually set the first responder like this, however:
[segmentedControl.window makeFirstResponder: segmentedControl];
That will work fine if the only part of the form is the segmented control. If I add another field (say, an NSTextField), and I set the nextResponder of the segmented control to that field, the segmented control will never become first responder. Focus will immediately go to the text field, and pressing tab to switch back to the segmented control doesn't work.
I've tried subclassing NSSegmentedControl and overriding acceptsFirstResponder, becomeFirstResponder, etc. to no avail. The only one that makes any difference is resignFirstResponder -- if I return NO from that method then the segmented control will indeed retain focus, but obviously I don't want it to retain focus all the time.
Any ideas on how to get the control to behave like a normal responder?
It's behaving as intended. Not all controls participate in the "key view loop". Full keyboard navigation is turned on through Universal Access in System Preferences for all apps and it's not for individual apps to implement on their own.
It's best not to use a segmented control in a form intended for heavy keyboard entry. NSPopUpButton works more closely to what we all exepect in a web form so it's not as if it's necessarily the wrong choice in your app's UI.
Rather than answer exactly the question you asked (which someone else can do), I humbly suggest you choose on the side of functionality at the cost of a slightly prettier UI element since that prettier UI element wasn't intended to get along with the keyboard.

Sheet popping out of a view

is it possible to have a sheet that pops out of a view? For example, I'd like to make it pop out of a bottom view in a NSSplitView.
I'm aware of popovers on Lion, but I need sheets since they are modal, they are available before Lion, and they are harder to dismiss.
AFAIK it's not possible and also not in line with Apple's UI guidelines. Obviously you could try to roll your own but that would involve a considerable amount of work.
EDIT: Actually, I think rolling your own is also difficult. The tools at hand are either a view or a window. I think you cannot use a view as views cannot draw themselves outside the frame of a window - unless you can somehow restrain your dialog within the bounds of the window that shows them. You would then need to setup the animation that shows the rolling sheet from your NSSplitView.
Windows are then the other alternative. To have them behave like modal sheets, you would want them borderless and by design they then cannot become a key window. So, the user would need to explicitly click the sheet to get focus which defies the purpose of a modal sheet in my opinion.
Both ways, a challenge...

Best way to create floating notification iOS

I've got a tabbed iPad application with just about each tab running a UIWebView. I'm getting all sorts of callbacks, like when a user tries to leave the corporate site (which only displays the company site to users). In this case, I pop up a "toast" style window that tells them to click a button to open the page in Safari. I also pop it up with a spinner and no text to indicate that a page is loading. The approximate look that I'm going for is used in lots of applications, but you can see it best when changing the volume on the iPhone or iPad. It's just a translucent rounded square that fades in and out.
Right now I've got it implemented on one of my tabs, and I did it by creating the objects (a spinner, a label, and a UIImage with the square) and then programmatically hiding and showing them using [UIView beginAnimations] and changing the label's text. It works perfectly but I've got these nagging things hovering over my interface in Xcode, and it takes a lot of setup to accomplish if I wanted it to be in another tab, which I do. I can't help but think that there's a better way to accomplish this. I thought about making and adding a subview, but that would leave a white background to the toast. What I'm thinking is creating some sort of object that I can allocate in a tab's view controller whenever it's needed.
What are your guys ideas, or have you done this in the past? I see it in a lot of prominent applications, like Reeder, so I'm sure it's been done more eloquently than I have done it.
Matt Gallagher has a great class called LoadingView here Showing message over iPhone Keyboard. I use it.
MBProgressHUD is a popular library for this, as well.