mouse event

Discussion in 'Mac Programming' started by stece, Oct 30, 2008.

  1. stece Guest

    Oct 9, 2008
    Dear all
    I have a code like this:

    #import <Cocoa/Cocoa.h>
    @interface Clasa : NSObject {
    	IBOutlet NSTextField *textField;
    #import "Clasa.h"
    @implementation Clasa
    - (IBAction)generate:(id)sender
    	int generated;
    	generated = (random()% 100) + 1;
    	NSLog(@"generated = %d", generated);
    	[textField setIntValue:generated];
    - (IBAction)seed:(id)sender
    	[textField setStringValue:@"Generator seeded"];
    and how does the computer know that if I push the button it is to
    show the int generated. I mean how does he know it in the function of time ( namely how does he know when to do it) because there is no mouseclick event defined or anything similar. So which event punctuates it and how?
    I read there are some actions, but how do these actions refer to the mouse click or push of the button?

    Thank you in advance
  2. SydneyDev macrumors 6502

    Sep 15, 2008
    The button object stores in it's member variables a pointer to another object, and the name of a method to call on that object when it is clicked.

    In Interface Builder, you create an instance of your object (above) and drag a line from the button to your object to set these member variables. The settings you make here are saved in the Interface Builder XIB file and restored at runtime.
  3. stece thread starter Guest

    Oct 9, 2008
    About using Apple documantation

    How to know from reference library of the NSButton which member variables are pointers to another object, and how to know which method they call if I click the button ?
  4. SydneyDev macrumors 6502

    Sep 15, 2008

Share This Page