Cannot get accessibility label/value for components in Mac app in XCTest - xctest

I am trying to access the elements in the UI Testing XCTest. I can able to access the accessibility label and values in the XCTest for some UI elements which is preset automatically. But some of the elements are found without the accessibility label or values. I want to know in what are the cases the accessibility label or values should not be preset or we cannot get the values in UI Testing?
I know one case. If the element is drawn in the drawRect method, we cannot access the UI component.

Accessibility labels will generally be set automatically for UI elements with text or values, like buttons, labels, text fields and sliders.
When you're writing UI tests, it's best practice to use the accessibilityIdentifier of an element instead of the accessibilityLabel.
You should set an accessibilityIdentifier on each view you want to be accessible to your UI tests. No views have preset accessibilityIdentifiers, so you will be in complete control.
#IBOutlet let signInButton: UIButton!
...
signInButton.accessibilityIdentifier = "signInButton"

Related

How to change the text alignment throughout the app at once?

Is there a way to change the alignment of all the textual elements (i.e textfileds, button titles, labels, navigation bar titles etc) throughout the app at once programatically? Actually I am developing a multi language app that has a language in which the text alignment is RTL. I dont want to set the alignment of every text element manually.There are some restrictions, so NSTectAlignmentNatural could not solve my problem. Actually the translations for languages arecoming through an API and that too in unicode format. So, how would the system detect what language is going to be displayed so that it could decide the alignment.
You can use UIAppearance to set properties of ui elements throughout your entire app. This will work for all classes that adopt the UIAppearance protocol (UILabel, UIButton, etc).
For eaxmple, the following code will change the text alignment of all labels in your app:
[[UILabel appearance] setTextAlignment:NSTextAlignmentRight];
IIRC, UINavigationBar does not support UIAppearance, meaning that you'll need to use a custom label for the title.
Replace all those elements with a thin custom class of your own creation that you can wire up to change this property based on the locale.

The RelativePanel layout control

I hear RelativePanel and SplitView are new layout controls for Windows 10. What is cool about the RelativePanel put as concisely as possible?
UWP is more focused on making a single app which will run on all the platforms. These panels are also called as Adaptive Panels. It has taken care of Adaptive UI very beautifully in app development.
RelativePanel is better than StackPanel to implement the desired layout for multiple screens using the same base code.
It has attached properties eg. RelativePanel.Below, RelativePanel.Above, RelativePanel.RightOf, RelativePanel.LeftOf which is very useful for making the different UI for different Device family using the same code.
RelativePanel is even more powerful when it is combined with VisualStateManager. You can see the example here.
MSDN has all the answers but here is a summary as concisely as
possible.
RelativePanel defines an area within which you can position and align
child objects in relation to each other or the parent panel. It is
essentially a layout container that is useful for creating UIs that
do not have a clear linear pattern; that is, layouts that are not
fundamentally stacked, wrapped, or tabular, where you might naturally
use a StackPanel or Grid. If your UI consists of multiple nested
panels, RelativePanel is a good option to consider.
Using RelativPanel's attached properties (such as
RelativePanel.Below, RelativePanel.Above, RelativePanel.RightOf,
etc), you can position a UI elment relative to another UI element as
well as relative to the panel (e.g.,
RelativePanel.AlignVerticalCenterWithPanel).
RelativePanel, used in conjunction with AdaptiveTriggers, can be a
powerful tool to create responsive UI that scales well across
different screen sizes. If you want to explore further on this, there
is a sample you can download and experiment with.

Sencha touch 2/ app workflow with navigation view

There is a problem with sencha touch 2.
I am trying to understand how can I implement the same functionality which provides navigation view in sencha touch 2, but ....
Each item of the 'Ext.NavigationView' component should have it's own unique set of 'navigationBar' elements. I mean set of buttons, for example.
I know that I can do something like this:
this.getMain().getNavigationBar().rightBox.removeAll();
this.getMain().getNavigationBar().rightBox.add(this.getSettingButton());
//where 'getSettingButton' predefined by me a button
And do this action each time when 'push' event happens (clear 'navigationBar' and add appropriate set of buttons)
Of course, I even can implement 'Ext.Panel' with 'layout: card' and set of 'Ext.panel' elements in the 'items' property, each of which will be have unique 'toolbar'.
To control the behavior I can use 'setActiveItem' method.
But, I think each of these approaches is a bit weird, isn't it?
I expected that would be much more natural approach to implement it.
Most likely I don't know what I need. Confirm my doubts. What is the best way to do it.
Currently, Ext.NavigationView tends to perform navigation between "simple" views. "Simple" here means that your views are just panel with innerHTML, not the "complicated" ones with functional buttons, toolbars, etc.
As far as I know, there're 2 ways you could try:
If you still want to use Ext.NavigationView, you can customize your NavigationBar with titles, items (buttons, spacers, etc.) as normal components through navigationBar config, getter and setter.
(recommended) If your views are completely different from each other, you should use many Ext.Container with different items of your choice (for eg. first container with simple HTML announcement, second one with some extra Ext.Button, and so on). Simple use animateActiveItem() for animated navigation. This way is much more flexible, I suppose.

How do I use an indeterminate status indicator as the image for an NSStatusItem?

I have an application that is an NSStatusItem.
It has a few different modes, each of which require an external process to be launched, during which the icon is simply highlighted, and appears to be frozen.
I want to use the -setImage: method (or reasonable facsimile) to display something along the lines of a "spinner" commonly seen in web applications and all over OS X.
Is there any native method for accomplishing this (e.g. some instance of NSProgressIndicator?) or must I manually display an animation by cycling through a set of images?
In either case, how would I implement?
In order to have it be animated (and not just a static image), you'll probably need to use -setView: and give it a custom view (which then animates itself). You might be able to get away with using a suitably-configured standard NSProgressIndicator (i.e. set to NSProgressIndicatorSpinningStyle style, etc.) as that "custom view".
But, if the NSProgressIndicator standard sizes don't work well, then you can check out my YRKSpinningProgressIndicator (BSD-licensed), which is a clone of the spinning NSProgressIndicator that can be set to arbitrary size and colors.

Adding visible elements to a custom Panel in Silverlight 3

As I understand it, a Panel isn't meant to have any visible "chrome." The StackPanel, Grid and Canvas don't have any visible elements (with the exception of the gridlines, which they say are only for debugging layout.)
In my example, I am going to create a Custom Panel that uses Attached Properties to lay out its children controls. However, I want my Custom Panel to present a visible "grid" of sorts in the background. The look of the grid (sizing and positioning) will depend on the size and position of the child elements.
What are some of the ways to achieve this? Being very new to Silverlight and XAML in general, my first guess was to create a Custom Control which includes my custom panel for layout.
I think I'll be able to figure out the specific code, but I need to be pointed in the right direction in terms of what building blocks are appropriate for this scenario.
You are correct that custom Panels cannot show any extra chrome; they can only display their Children (Grid being an exception).
To do what you want to do, you could create a custom Panel which just adds extra Children to display the chrome. This would not be a good design though (since users of the Panel would see these extra items in the Children collection).
The best idea is to do what you said: create a custom Control that exposes a Children property. This control could internally use a private custom Panel to lay out these elements (e.g. TabControl uses a special TabPanel for laying out the tabs). In the Controls default template, you might want to use TemplateBinding on the Panels' Children property to your Control's Children property.
Panel can add Adorners to its children, read this article about adorners: http://msdn.microsoft.com/en-us/library/ms743737.aspx