Thread View: comp.sys.next.programmer
2 messages
2 total messages
Started by rowley Tim Rowley
Tue, 21 Jul 1992 19:17
Keyboard input
Author: rowley Tim Rowley
Date: Tue, 21 Jul 1992 19:17
Date: Tue, 21 Jul 1992 19:17
70 lines
2273 bytes
2273 bytes
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
Re: Keyboard input
Author: Eric P. Scott
Date: Wed, 22 Jul 1992 07:45
Date: Wed, 22 Jul 1992 07:45
20 lines
1113 bytes
1113 bytes
In article <1992Jul21.191759.3408@news2.cis.umn.edu> rowley@leghorn.cs.umn.edu. (Tim Rowley) writes: >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. >This was slightly more successful in that I now get the mouseDown events, but >pressing a key just gives a miserable "boink." Does your View implement an acceptsFirstResponder method that returns YES? [Read the description of acceptsFirstResponder (Responder) in the NeXTstep Reference.] Also, have you done [the equivalent of] [[NXApp mainWindow] makeFirstResponder:thatView] ? -=EPS=-
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads