Keywords: manual

Next: 3. Additional portability facilities Up: 2. The GNUstep Markup Previous: 2.8 Connector tag reference

# 2.9 Example

FIXME: this example should be replaced with a better one.

FIXME: add examples of advanced outlets.

    <?xml version="1.0"?>
    <!DOCTYPE gsmarkup>
    <gsmarkup>

    <objects>
     <!-- the main window -->
     <window title="Calculator" resizable="no" closable="no">

       <vbox>

         <textfield editable="no" id="TextField" />

         <hbox>
          <button title="1" target="#Controller" action="digit:" />
          <button title="2" target="#Controller" action="digit:" />
          <button title="3" target="#Controller" action="digit:" />
         </hbox>

         <hbox>
          <button title="4" target="#Controller" action="digit:" />
          <button title="5" target="#Controller" action="digit:" />
          <button title="6" target="#Controller" action="digit:" />
         </hbox>

         <hbox>
          <button title="7" target="#Controller" action="digit:" />
          <button title="8" target="#Controller" action="digit:" />
          <button title="9" target="#Controller" action="digit:" />
         </hbox>

         <hbox>
          <button title="+" target="#Controller" action="add:" />
          <button title="0" target="#Controller" action="digit:" />
          <button title="=" target="#Controller" action="total:" />
         </hbox>

       </vbox>

     </window>

     <!-- an object of a custom class, which is instantiated when the nib
          is loaded.  Key-value coding is used to set textField to #TextField.
          In other words, the textField attribute is equivalent to having a
          NSNibOutletConnector with source #Controller, target #TextField,
          and key textField -->
     <instance instanceOf="CalculatorController" id="Controller"
               textField="#TextField" />

    </objects>

    <!-- in this example, connectors are not actually needed (or better
         all connectors are embedded in the objects section) - but we add
         the connectors section as an example.  -->
    <connectors>

     <!-- an example of a standalone connector, needed to connect the Controller
          to the controller ivar (or setController: method) of the NSOwner (the
          object which loaded the nib).  This connector must be standalone
          because #NSOwner is not inside the nib.  (you can reference objects
          totally outside the nib in a connector, which are provided by the
          nameTable dictionary when the nib is loaded) -->
     <outlet source="#NSOwner" target="#Controller" key="controller" />

    </connectors>

    </gsmarkup>