home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!dtix!darwin.sura.net!mips!news.cs.indiana.edu!umn.edu!news
- From: rowley@leghorn.cs.umn.edu. (Tim Rowley)
- Newsgroups: comp.sys.next.programmer
- Subject: Keyboard input
- Keywords: keyboard, events
- Message-ID: <1992Jul21.191759.3408@news2.cis.umn.edu>
- Date: 21 Jul 92 19:17:59 GMT
- Sender: news@news2.cis.umn.edu (Usenet News Administration)
- Distribution: usa
- Organization: University of Minnesota
- Lines: 70
- Nntp-Posting-Host: leghorn.cs.umn.edu
-
- This has to be a FAQ, but here goes:
-
- I want keyboard events from the main window of my application. Sounds simple
- enough, but I'm having problems.
-
- I have a view with the following things overridden: keyDown and mouseDown.
-
- First I tried the following:
-
- #import <stdlib.h>
- #import <appkit/Application.h>
- #import "MyView.h"
-
- void main(int argc, char *argv[]) {
- id mv;
-
- NXApp = [Application new];
- [NXApp loadNibSection:"t.nib" owner:NXApp];
- mv = [[MyView alloc] init];
- [[NXApp mainWindow] setContentView:mv];
- [NXApp run];
- [NXApp free];
- exit(0);
- }
-
- This doesn't get me the keyboard or mouse events.
-
- Next I tried making my own window and then doing stuff with it:
-
- #import <stdlib.h>
- #import <appkit/Application.h>
- #import <appkit/appkit.h>
- #import "MyView.h"
-
- void main(int argc, char *argv[]) {
- id mv;
- id theWindow;
- NXRect aRect;
-
- NXApp = [Application new];
- [NXApp loadNibSection:"t.nib" owner:NXApp];
-
- NXSetRect(&aRect, 100.0, 350.0, 300.0, 300.0);
- theWindow = [Window newContent:&aRect /* create Window */
- style:NX_TITLEDSTYLE /* object */
- backing:NX_BUFFERED
- buttonMask:NX_ALLBUTTONS
- defer:NO];
- [theWindow setBackgroundGray:NX_WHITE];
-
- mv = [[MyView alloc] init];
-
- [theWindow setContentView: mv];
-
- [theWindow display];
- [theWindow orderFront:nil];
- [theWindow makeKeyWindow];
-
- [NXApp run];
- [NXApp free];
- exit(0);
- }
-
- This was slightly more successful in that I now get the mouseDown events, but
- pressing a key just gives a miserable "boink."
-
- Could anyone give me a clue to what's happening?
-
- - Tim Rowley
- rowley@leghorn.cs.umn.edu
-