Changeset 8559


Ignore:
Timestamp:
Feb 22, 2008, 6:30:29 AM (12 years ago)
Author:
mikel
Message:

edits to button section of UI HOWTO

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/examples/cocoa/ui-elements/HOWTO.html

    r8523 r8559  
    9797    that we need only temporarily. Because <code>NSRect</code> values
    9898    appear so often in Cocoa code, Clozure CL provides a handy way to
    99     allocate them values temporarily, disposing of them
     99    allocate them temporarily, disposing of them
    100100    automatically. The <code>with-ns-rect</code> macro (in
    101101    the <code>NS</code> package) creates an <code>NSRect</code> value,
     
    108108    </pre>
    109109
    110     <p>The macro creates a temporary <code>NSRect</code> value,
    111     visible to any code in the body of the
    112     macro. The <code>NSRect</code> value is automatically dispose at
    113     the end of the macro form. We can use this rectangle to initialize
    114     the shape of our new window:</p>
     110    <p>We can use this rectangle to initialize the shape of our new
     111    window:</p>
    115112
    116113    <pre>
     
    266263    </pre>
    267264
    268     <p>Now we just need to add the button to the window:</p>
     265    <p>Now we just need to add the button to the window. This we do by
     266    asking the window for its content view, and asking that view to
     267    add the button as a subview:</p>
    269268
    270269    <pre>
     
    273272
    274273    <p>The button appears in the window with the rather uninspired
    275     label "Button". Clicking it highlights the button but, since we
     274    title "Button". Clicking it highlights the button but, since we
    276275    didn't give it any action to perform, does nothing else.</p>
    277276
    278     <p>We can give the button a more interesting label and, perhaps
     277    <p>We can give the button a more interesting title and, perhaps
    279278    more importantly, an action to perform, by passing a string and an
    280279    action to it. First, let's set the button title:</p>
     
    290289
    291290    <p>The button changes to display the text "Hello!". Notice that we
    292     are careful to save a reference to the label text and release it
     291    are careful to save a reference to the button text and release it
    293292    after changing the button title. The normal memory-management
    294293    policy in Cocoa is that if we allocate an object (like the
     
    323322
    324323    <p>We'll need to define a method to execute in response to the
    325     button's message. Action methods accept one argument (inaddition
     324    button's message. Action methods accept one argument (in addition
    326325    to the receiver): a sender. Normally Cocoa passes the button
    327326    object itself as the sender argument; the method can do anything
    328     it likes (oor nothing at all) with the sender.</p>
     327    it likes (or nothing at all) with the sender.</p>
    329328
    330329    <p>Here's a method that displays an alert dialog:</p>
     
    341340    (#/release title)
    342341    (#/release msg)
    343     (#/release default-button)))
     342    (#/release default-button)
     343    (#/release other-button)))
    344344    </pre>
    345345
Note: See TracChangeset for help on using the changeset viewer.