Hi,
I want to write an application without using a nib file.
I found same code that do this and it works, but I am not able to manage
event. For exactly I want to trap some event (tablet event) and manage this.
So, I write this code:

- main.m -------------------------------------
import <Cocoa/Cocoa.h>
#import "myView.h"

int main(int argc, const char *argv[])
{
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
    NSWindow *window;
    myView *view;
    view = [[myView alloc] initWithFrame:NSMakeRect(0,100,200,200) ];

window = [[NSWindow alloc] initWithContentRect:NSMakeRect(50,100,200,300)
                                         styleMask:NSTitledWindowMask | 
NSResizableWindowMask
                                           backing:NSBackingStoreBuffered
                                             defer:TRUE];


NSButton *button=[[NSButton alloc]initWithFrame:NSMakeRect(10,10,180,32) ];
    [button setBezelStyle:NSRoundedBezelStyle];
    [button setTitle:@"Quit"];
    [button setTarget:NSApp];
    [button setAction:@selector(terminate:)];

    [[window contentView] addSubview:button];

    [NSApplication sharedApplication];
    [window makeKeyAndOrderFront: nil];
    [pool release];

    [NSApp run];
    return 0;
}
 -----------------------------------
- myView.h ----------------------------------
#import <Cocoa/Cocoa.h>

@interface myView : NSView
{
}
- (id)initWithFrame:(NSRect)frame;
- (BOOL)acceptsFirstResponder;
- (void)tabletProximity:(NSEvent *)theEvent;
@end
 -----------------------------------

- myView.m ------------------------------------------
#import "myView.h"

@implementation myView
- (id)initWithFrame:(NSRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        printf("Parto..\n");
    }
    return self;
}

- (BOOL)acceptsFirstResponder
{
    return YES;
}
- (void)tabletProximity:(NSEvent *)theEvent
{
        printf("prossimita'\n");
    if([theEvent isEnteringProximity])
    {
        printf("Entro\n");
        printf("capabilityMask(%d)\n", [theEvent capabilityMask]);
                printf("deviceID(%d)\n", [theEvent deviceID]);
                printf("enterProximity(%d)\n", [theEvent isEnteringProximity]);
                printf("pointerID(%d)\n", [theEvent pointingDeviceID]);
printf("pointerSerialNumber(%d)\n", [theEvent pointingDeviceSerialNumber]);
                printf("pointerType(%d)\n", [theEvent pointingDeviceType]);
                printf("systemTabletID(%d)\n", [theEvent systemTabletID]);
                printf("tabletID(%d)\n", [theEvent tabletID]);
                printf("uniqueID(%d)\n", [theEvent uniqueID]);
                printf("vendorID(%d)\n", [theEvent vendorID]);
printf("vendorPointerType(%d)\n", [theEvent vendorPointingDeviceType]);
    }
    else
    {
        printf("Esco\n");    }

}
@end
--------------------------------------------------

This code draw a window with one button that, I press it, the program quit. I see the window and button work, but the myView class seem not receive the windows events..

Have any idea for this?

Thanks
Daniele.

--
|  [D]-o Ing. Daniele Basile - [EMAIL PROTECTED]
|   ||}-o  Develer S.r.l., R&D dept.
|  [B]-o  http://www.develer.com - http://www.bertos.org






_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to