Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Nolis

macrumors newbie
Original poster
Jun 17, 2011
3
0
Hey guys,
I coded a simple cocoa webbrowser app with WebView, this Browser loads only an homepage, wihtout browser navigation or address line.. so basicly a simple fullscreen webbrowser. It resize to an fullscreen app:
Code:
styleMask:NSBorderlessWindowMask

the Problem is when I use: NSBorderlessWindowMask I loose the Keyfunktion and also the html css onmouseover styles dosn't work... if I change it to an: NSTitledWindowMask everything works fine.. bun not in Fullscreen... can anyone help my out.. please notice that I'm bloody beginner in Xcode.

here is my .h file
Code:
#import <Cocoa/Cocoa.h>
#import <WebKit/WebKit.h>



@interface TimeWarpAppDelegate : NSObject <NSApplicationDelegate> {
    NSWindow *window;
	IBOutlet WebView*webview;

		
}

@property (assign) IBOutlet NSWindow *window;


@end

here is my .m file
Code:
#import "TimeWarpAppDelegate.h"


@implementation TimeWarpAppDelegate



@synthesize window;


- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
	// Insert code here to initialize your application 
	
	
	
	
	[webview setDrawsBackground:NO];
	
	
	[window orderOut:self];
    NSRect screenRect = [[NSScreen mainScreen] frame];
    NSView * iv = [window contentView];
    self.window = [[NSWindow alloc] initWithContentRect:screenRect
// styleMask:NSTitledWindowMask
styleMask:NSBorderlessWindowMask
backing:NSBackingStoreBuffered
defer:NO screen:[NSScreen mainScreen]];
[self.window setContentView:iv];
[self.window setLevel:CGShieldingWindowLevel()];
[self.window makeKeyAndOrderFront:nil];  
		
	NSURL*url=[NSURL URLWithString:@"http://localhost/"];
    NSURLRequest*request=[NSURLRequest requestWithURL:url];
    [[webview mainFrame] loadRequest:request];
	

}

- (BOOL)canBecomeKeyWindow
{
	return YES;
}

@end

greetz Noli ;-)
 
canBecomeKeyWindow is a method on NSWindow, so you need to subclass NSWindow, add that method into your subclass, then use your subclass instead of NSWindow when creating your window.
 
I added a new class named it: activeView and put into activeView.h
Code:
#import <Cocoa/Cocoa.h>


@interface activeView : NSWindow {

}

@end
and I put this into the activeView.m
Code:
#import "activeView.h"


@implementation activeView


- (BOOL)canBecomeKeyWindow
{
	return YES;
}

- (BOOL)canBecomeMainWindow
{
	return YES;
}


@end
I set the Class "NSWindow" from the MainWindow to "activeView" ...but it don't work... whats wrong ?
 
In your applicationDidFinishLaunching: method, you're re-creating the window manually, but using NSWindow instead of your subclass. You need to change that to your subclass.
 
I'm a bloody beginner, and I'm try very hard to it... can you please give me an code example.. ?

greetz Noli ;-)
 
here is my .m file
Code:
#import "TimeWarpAppDelegate.h"

@implementation TimeWarpAppDelegate

@synthesize window;


- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
	// Insert code here to initialize your application 
	
	[webview setDrawsBackground:NO];
	
	
	[window orderOut:self];
    NSRect screenRect = [[NSScreen mainScreen] frame];
    NSView * iv = [window contentView];
    self.window = [[COLOR="Red"][NSWindow alloc][/COLOR] initWithContentRect:screenRect
// styleMask:NSTitledWindowMask
styleMask:NSBorderlessWindowMask
backing:NSBackingStoreBuffered
defer:NO screen:[NSScreen mainScreen]];
[self.window setContentView:iv];
[self.window setLevel:CGShieldingWindowLevel()];
[self.window makeKeyAndOrderFront:nil];  
		
	NSURL*url=[NSURL URLWithString:@"http://localhost/"];
    NSURLRequest*request=[NSURLRequest requestWithURL:url];
    [[webview mainFrame] loadRequest:request];

}
If you understand what the red-hilited code is doing, and what kainjow wrote, then you should know how to fix it.

If you don't understand what the red-hilited code is doing, then you should pick a simpler project at this time. You're in over your head.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.