Is it possible to receive notifications if, for a specific parent AXUIelement, any of it's children change (an attributes), or a child is added/removed?
For added/removed You can get notified if an element is created with NSAccessibilityCreatedNotification (and then check if it has the appropriate parent) and destroyed with NSAccessibilityUIElementDestroyedNotification. I don't see a accessibility notification for arbitrary attribute changes.
Related
I am confused about components data.
Parent to Child use props.
Child to Parent use emit.
I am thinking about difference.
What I have learned, emit need event to transfer data.
So, the example, I learned it always combine event like 'click'
This is point what I confused.
Why child to parent need emit event to send data.
I am think about are there certain way send data from child to parent no use event?
I understand the use and need of target-actions.
But I encountered this concept of "First Responder".
Can someone explain why is it needed? What can it do that can't be done using target-actions?
In an app, the responder object that first receives many kinds of events is known as the first responder. It receives key events, motion events, and action messages, among others. (Mouse events and multitouch events first go to the view that is under the mouse pointer or finger; that view might or might not be the first responder.) The first responder is typically the view in a window that an app deems best suited for handling an event. To receive an event, the responder must also indicate its willingness to become first responder; it does this in different ways for each platform
When you design your app, it’s likely that you want to respond to events dynamically. For example, a touch can occur in many different objects onscreen, and you have to decide which object you want to respond to a given event and understand how that object receives the event.
When a user-generated event occurs, UIKit creates an event object containing the information needed to process the event. Then it places the event object in the active app’s event queue. For touch events, that object is a set of touches packaged in a UIEvent object. For motion events, the event object varies depending on which framework you use and what type of motion event you are interested in.
An event travels along a specific path until it is delivered to an object that can handle it. First, the singleton UIApplication object takes an event from the top of the queue and dispatches it for handling. Typically, it sends the event to the app’s key window object, which passes the event to an initial object for handling. The initial object depends on the type of event.
Touch events. For touch events, the window object first tries to deliver the event to the view where the touch occurred. That view is known as the hit-test view. The process of finding the hit-test view is called hit-testing, which is described in the “Hit-Testing Returns the View Where a Touch Occurred.” doc.
For Motion and remote control events. With these events, the window object sends the shaking-motion or remote control event to the first responder for handling. The first responder is described in “The Responder Chain Is Made Up of Responder Objects.”
The ultimate goal of these event paths is to find an object that can handle and respond to an event. Therefore, UIKit first sends the event to the object that is best suited to handle the event. For touch events, that object is the hit-test view, and for other events, that object is the first responder.
For more info, look here...
I'm learning about design patterns and I have stumbled upon a question I really don't know how to find an answer to. In the observer design pattern class diagrams, I have seen that a Concrete Observer usually has a reference to the Subject. But, who sets the value of that reference? And how Attaching function gets called? Do observers call it themselves according to the subject reference they have, or somebody else sets the subject and then attaches the observer to the subject? I've looked for examples, but I'm still having troubles finding the best way to implement this.
The observer is the component that wants to be notified about changes or events of the subject. It decides to observe the subject and adds itself to the list of observers that the subject maintains.
The typical use-case is a graphical panel containing a button. The graphical panel creates a button and adds it to itself. And it wants to display a dialog box every time the button is clicked. So it adds itself as an observer of the button, and the button notifies the panel when it's clicked.
In this example, the observer creates the object it observes. But there are situations where that is not the case, and when the reference to the subject is passed as an argument to its constructor or one of its methods. This is irrelevant to the principle of the observer pattern itself.
The Subject is an object which controls some event or has some property which the Observers are interested in. The Observers register themselves with the Subject to express that interest, and the Subject keeps a list of those registered Observers.
When the Subject's property changes, or the event of interest occurs, the Subject iterates through its list of registered Observers and notifies them of the change or event.
The specifics of how the Observers are notified can vary. It may be that they have a well known method that gets called. It may be that they specify a custom method that they want called, which they specify as part of the registration process.
In a Cocoa application is there a standard pattern for keeping UI and other element states in sync? For example I have the main Menu managed by one class and a toolbar managed by another. Some of the menu items must reflect current selections in the toolbar and vice versa. I was going to handle this by having the selector triggered by the menu items and toolbar items fire off a Notification. The controlling classes would subscribe to these an update the UI to match the selection. Is this a good way to do this or am I missing some other natural way to do this in Cocoa?
For the specific case of whether an item should be enabled or disabled, that should be left to the target (or the implicit target if the target is the first responder). It should use User Interface Validation for that.
Bindings is another good technique. The state which governs the UI should either be in the model or the controller, and the UI should bind to it. (If the UI is to bind to the model, it should be through the controller.) That way, you only have to make sure the state is up-to-date and consistent and everything else happens automatically.
But then the technique you describe is a good third option. The model should provide notifications (through NSNotifications or a delegate) to the controller layer when it has changed. The controller layer watches those and has intimate knowledge about what effect state changes should have on the UI and explicitly configures the UI to conform.
Why do I need to add relationships for child and parent?
Child child = Session.Get(1);
Parent parent = Session.Load(1);
parent.Children.Add(child);
child.Parent = parent;
It works perfectly without parent.Children.Add(child) if use inverse=true and I don't need Children collection in current session (session per web request). Do you always add relationship for child and parent?
Setting child.Parent = parent is enough to persist the relationship.
However, if you don't add the child to the collection, you won't be able to take advantage of cascading, so you'll have to persist the child explicitly.
Also, if you don't set one of the sides, you'll have an inconsistent memory model (because the child won't be added to the collection unless you reload it).
I hope I understood you correctly.
class Parent { List Children {get;set;}
class Child { Parent Parent {get;set;}
ANS1. In this scenario Inverse tells the nhibernate framework to leave the control mechanism of [Parent-Child] relationship to the Child (it is mostly about which object is responsible for Deleting/Updating the Child). With Inverse attribute on Children property Child is responsible for itself, otherwise Parent is responsible for deleting a Child.
ANS2. You do not need both properties (Children, Parent) in most cases (you need them if you specify inverse=true on Children). It only depends on the functionality you want to get.
Does this briefly answer your question?