Igor Delovski Board Forum Index Igor Delovski Board
My Own Personal Slashdot!
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Nibless Cocoa

 
Post new topic   Reply to topic    Igor Delovski Board Forum Index -> Mac Cocoa
Mac Cocoa  
Author Message
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3136
Location: Europe

PostPosted: Sat Jul 23, 2022 4:57 pm    Post subject: Nibless Cocoa Reply with quote

git - Nibless Cocoa

"A combination of several blog posts / other sites to create a functional Nibless
Cocoa App, a Nibless Cocoa OpenGL App and a Nibless Cocoa Metal App in
macOS Sierra 10.12."
Back to top
View user's profile Send private message
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3136
Location: Europe

PostPosted: Sat Jul 23, 2022 4:57 pm    Post subject: Reply with quote

Jeff Johnson - Working without a nib, Part 10: Mac Main Menu

"In a nutshell, to create a Mac main menu programmatically, you just need to
create a new NSMenu instance, populate the menu, and set your instance as
the mainMenu of the application (AKA NSApp)

This can all be done using public API allowed in the Mac App Store. You'll notice
that there is no NSApplicationMain in the app. Instead we call the NSApplication
function run(). The main purpose of NSApplicationMain is to load objects from
your app's main nib or storyboard, so it's not needed when your app is nibless."


Working without a nib, Part 8: The nib awakens

Working without a nib, Part 7: The empire strikes back

Working without a nib, Part 6: Working without a xib

Working without a nib, Part 1
Back to top
View user's profile Send private message
XNote
Kapetan


Joined: 16 Jun 2006
Posts: 532

PostPosted: Sat Jul 23, 2022 5:13 pm    Post subject: Reply with quote

Working without a nib, Part 2: Also Also Wik

http://lapcatsoftware.com/downloads/Nibless.zip

Working without a nib, Part 5: No, 3!

Working without a nib, Part 4: setAppleMenu

Working without a nib, Part 5: Open Recent menu

http://lapcatsoftware.com/downloads/NiblessLeopard2.zip
Back to top
View user's profile Send private message
XNote
Kapetan


Joined: 16 Jun 2006
Posts: 532

PostPosted: Sat Jul 23, 2022 7:20 pm    Post subject: Reply with quote

hyperjeff - Nibless Window Example

"No frills code to bring up a Cocoa window without using nib files"
Back to top
View user's profile Send private message
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3136
Location: Europe

PostPosted: Mon Jun 19, 2023 10:31 pm    Post subject: Reply with quote

sarunw - How to create a new Xcode project without Storyboard

"When you create a new project in Xcode, the default boilerplate includes the
Main.storyboard. If you are going with a no storyboard approach and want to
set everything up in code, there are a few steps you need to take."
Back to top
View user's profile Send private message
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3136
Location: Europe

PostPosted: Thu Aug 10, 2023 2:48 pm    Post subject: Reply with quote

so - How do I create a Cocoa window programmatically?

"A side note, if you want to programatically instantiate the application
without a main nib, in the main.m file / you can instantiate the AppDelegate
as below. Then in your apps Supporting Files / YourApp.plist Main nib base
file / MainWindow.xib delete this entry. Then use Jason Coco's approach to
attach the window in your AppDelegates init method."


Code:
#import "AppDelegate.h":

int main(int argc, char *argv[])
{

  NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
  [NSApplication sharedApplication];

  AppDelegate *appDelegate = [[AppDelegate alloc] init];
  [NSApp setDelegate:appDelegate];
  [NSApp run];
  [pool release];
  return 0;
}


"This code will create your borderless, blue window at the bottom left of the
screen:"


Code:
NSRect frame = NSMakeRect(0, 0, 200, 200);
NSWindow* window  = [[[NSWindow alloc] initWithContentRect:frame
                    styleMask:NSBorderlessWindowMask
                    backing:NSBackingStoreBuffered
                    defer:NO] autorelease];
[window setBackgroundColor:[NSColor blueColor]];
[window makeKeyAndOrderFront:NSApp];
Back to top
View user's profile Send private message
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3136
Location: Europe

PostPosted: Mon Aug 14, 2023 4:57 pm    Post subject: Reply with quote

so - How to create a menu programmatically without any interface builder files in MacOS?

Code:
- (void) menuAction: (id)sender {
 NSLog(@"%@", sender);
}

- (void) buildMenu {
 // **** Menu Bar **** //
 NSMenu *menubar = [NSMenu new];
 [NSApp setMainMenu:menubar];
 // **** App Menu **** //
 NSMenuItem *appMenuItem = [NSMenuItem new];
 NSMenu *appMenu = [NSMenu new];
 [appMenu addItemWithTitle: @"Quit" action:@selector(terminate:) keyEquivalent:@"q"];
 [appMenuItem setSubmenu:appMenu];
 [menubar addItem:appMenuItem];
 // **** File Menu **** //
 NSMenuItem *fileMenuItem = [NSMenuItem new];
 NSMenu *fileMenu = [[NSMenu alloc] initWithTitle:@"File"];
 [fileMenu addItemWithTitle:@"New" action:@selector(menuAction:) keyEquivalent:@""];
 [fileMenu addItemWithTitle:@"Open" action:@selector(menuAction:) keyEquivalent:@""];
 [fileMenu addItemWithTitle:@"Save" action:@selector(menuAction:) keyEquivalent:@""];
 [fileMenuItem setSubmenu: fileMenu];
 [menubar addItem: fileMenuItem];
}
Back to top
View user's profile Send private message
Ike
Kapetan


Joined: 17 Jun 2006
Posts: 3136
Location: Europe

PostPosted: Thu Aug 17, 2023 1:51 pm    Post subject: Reply with quote

git - SDL-mirror/src/video/cocoa/SDL_cocoaevents.m

Code:
    /* Create the application menu */
    appName = GetApplicationName();
    appleMenu = [[NSMenu alloc] initWithTitle:@""];

    /* Add menu items */
    title = [@"About " stringByAppendingString:appName];
    [appleMenu addItemWithTitle:title action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""];

    [appleMenu addItem:[NSMenuItem separatorItem]];

    [appleMenu addItemWithTitle:@"Preferences..." action:nil keyEquivalent:@","];

    [appleMenu addItem:[NSMenuItem separatorItem]];

    serviceMenu = [[NSMenu alloc] initWithTitle:@""];
    menuItem = (NSMenuItem *)[appleMenu addItemWithTitle:@"Services" action:nil keyEquivalent:@""];
    [menuItem setSubmenu:serviceMenu];

    [NSApp setServicesMenu:serviceMenu];
    [serviceMenu release];

    [appleMenu addItem:[NSMenuItem separatorItem]];

    title = [@"Hide " stringByAppendingString:appName];
    [appleMenu addItemWithTitle:title action:@selector(hide:) keyEquivalent:@"h"];

    menuItem = (NSMenuItem *)[appleMenu addItemWithTitle:@"Hide Others" action:@selector(hideOtherApplications:) keyEquivalent:@"h"];
    [menuItem setKeyEquivalentModifierMask:(NSEventModifierFlagOption|NSEventModifierFlagCommand)];

    [appleMenu addItemWithTitle:@"Show All" action:@selector(unhideAllApplications:) keyEquivalent:@""];

    [appleMenu addItem:[NSMenuItem separatorItem]];

    title = [@"Quit " stringByAppendingString:appName];
    [appleMenu addItemWithTitle:title action:@selector(terminate:) keyEquivalent:@"q"];
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Igor Delovski Board Forum Index -> Mac Cocoa All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Delovski.hr
Powered by php-B.B. © 2001, 2005 php-B.B. Group