Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture 9 The most important GUI elements

Similar presentations


Presentation on theme: "Lecture 9 The most important GUI elements"— Presentation transcript:

1 Lecture 9 The most important GUI elements
Windows, Views, Buttons

2 The NSWindow Every graphics application needs at least one window.
We cannot draw in Windows but we can draw in Views The window contains a ContentView. We can add subviews to the ContentView.

3 The NSView A View can be put in the window by means of the content view. A view can have any number of subViews. A subview of a view will never extend beyond the range of its superview. Views that are siblings should not overlap, because the sequence in which the siblings are displayed is undetermined.

4 The NSButton NSButton is derived from NSView, it inherits all methods from NSView, can be added to a view, can be initialized like a view, etc. There are special methods for initializing buttons. There are special ways for adding callbacks to buttons (the taget-action design pattern).

5 The NSResponder NSWindow, NSView, NSApplication are all derived from NSResponder. NSResponder contains all important Event messages, that our application needs. We can make our application respond to these events by overriding the inherited Event messages.

6 The Application Delegate
If we wish we can write a class that implements the NSApplicationDelegate protocol. If we add an object of this class as a delegate to NSApplication, then the implemented methods will be called at certain points during running of the application. We can do anything we wish in these methods, but they serve mainly to structure our application code and customize the behaviour of the application.

7 The target-action pattern
This pattern makes Cocoa graphics programming very easy and powerful. Any method of any object can be made into a callback for a button click or other GUI event. Actions and targets can be changed dynamically at run time. Programming examples in the lecture will make this clear.


Download ppt "Lecture 9 The most important GUI elements"

Similar presentations


Ads by Google