Can't edit text in overlay window
Can't edit text in overlay window
- Subject: Can't edit text in overlay window
- From: David Rice <email@hidden>
- Date: Wed, 24 Aug 2005 10:51:44 -0400
I have a test app based on the "Movie Overlay" sample code. I have a
window with a movie view and a child window with an NSTextView as a
subview. The textView is "working" in that I can insert text and it
is displayed with [myTextView insertText:@"Blah Blah."];
I can select the text and perform some operations on it but I cannot
type new text or delete existing text. If I activate a ruler I can
apply existing styles to selected text.
I'm obviously missing something. What do I need to do to be able to
edit the text in myTextView?
Here is the code I've got to create the overlay window:
- (void)awakeFromNib
{
NSRect movieViewBounds, subViewRect;
if ([[self superclass] instancesRespondToSelector:@selector
(awakeFromNib)])
{
[super awakeFromNib];
}
// setup our NSMovieView
[self initMovieView];
NSPoint baseOrigin, screenOrigin;
baseOrigin = NSMakePoint([movieView frame].origin.x,
[movieView frame].origin.y);
// convert our NSMovieView coords from local coords to screen
coords
// which well use when creating our NSWindow below
screenOrigin = [movieWindow convertBaseToScreen:baseOrigin];
// Create an overlay window which will be attached as a child
// window to our main window. We will create it directly on top
// of our main window, so when we draw things they will appear
// on top of our playing movie
overlayWindow=[[NSWindow alloc] initWithContentRect:NSMakeRect
(screenOrigin.x,
screenOrigin.y,
[movieView frame].size.width,
[movieView frame].size.height)
styleMask:NSBorderlessWindowMask
backing:NSBackingStoreBuffered defer:YES];
[overlayWindow setOpaque:NO];
[overlayWindow setHasShadow:NO];
movieViewBounds = [movieView bounds];
subViewRect = NSMakeRect(movieViewBounds.origin.x,
movieViewBounds.origin.y,
movieViewBounds.size.width,
movieViewBounds.size.height);
myTextView = [[NSTextView alloc] initWithFrame:subViewRect];
[[overlayWindow contentView] addSubview:myTextView];
scrollView = [[NSScrollView alloc] initWithFrame:subViewRect];
[[overlayWindow contentView] addSubview: scrollView];
[scrollView setDrawsBackground:NO];
[scrollView setHasVerticalScroller:YES];
[scrollView setDocumentView:myTextView];
[myTextView setTextColor:[NSColor colorWithCalibratedRed:0.0
green:0.0
blue:1.0
alpha:0.8]];
[myTextView setFont:[NSFont userFontOfSize:20]];
[myTextView setBackgroundColor:[NSColor colorWithCalibratedRed:1.0
green:
1.0
blue:1.0
alpha:
0.0 ]];
[myTextView setFont:[NSFont userFontOfSize:20]];
[myTextView insertText:@"\n\n\n1TEXT Goes Here."];
// add our overlay window as a child window of our main window
[movieWindow addChildWindow:overlayWindow ordered:NSWindowAbove];
[overlayWindow orderFront:self];
return ;
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden