Giter Club home page Giter Club logo

Comments (4)

gf3 avatar gf3 commented on July 18, 2024

I ended up adding a text field and simply modifying that. I also added a setTitle method to my application controller.

from inappstorewindow.

loretoparisi avatar loretoparisi commented on July 18, 2024

Good idea, I'm trying this way.

Strange thing, if you look at the header file it says

 /** The title bar view itself. Add subviews to this view that you want to show in the title bar (e.g. buttons, a toolbar, etc.).      This view can also be set if you want to use a different styled title bar aside from the default one (textured, etc.). **/
 @property (nonatomic, retain) NSView *titleBarView;

So it seems that the default title should work.
Looking at the code you can found the title setter

 - (void)setTitle:(NSString*)title
 {
self.windowMenuTitle = title;
if ( ![self isExcludedFromWindowsMenu] )
    [NSApp changeWindowsItem:self title:self.windowMenuTitle filename:NO];
 }

The problem is the

[NSApp changeWindowsItem:aWindow title:[titleView stringValue] filename:NO];

Now if you look at Chromium it does something similar

http://src.chromium.org/svn/trunk/src/chrome/browser/ui/cocoa/fullscreen_window.mm

Since there's no reason the api is not working properly, there sholud be some drawing issue in the

- (void)drawRect:(NSRect)dirtyRect

from inappstorewindow.

loretoparisi avatar loretoparisi commented on July 18, 2024

I'm not happy with the solution of subviewing the titleBarView since it needs extra code handling the title bar color changing when going from frontmost to background.
A very basic test is doing something like this

 NSSize titleSize=NSMakeSize(120.0,20.0);
 NSTextField *titleView = [[NSTextField alloc] initWithFrame:
                          NSMakeRect(aWindow.titleBarView.frame.size.width/2-titleSize.width/2, 
                                     aWindow.titleBarView.frame.size.height/2-titleSize.height/2, titleSize.width, titleSize.height)];
[titleView setBackgroundColor:[NSColor clearColor]];
[titleView setBezeled:NSNoBorder]; // remove the bezeled border
[titleView setEditable:NO];
[titleView setStringValue:@"Window Title"];
[titleView setTextColor:[NSColor grayColor]];

[[aWindow titleBarView] addSubview:titleView];

// handling color control color changes in NSWindow handler?

from inappstorewindow.

indragiek avatar indragiek commented on July 18, 2024

There is no title on the window because the title bar view covers the default title bar (including the window title). The text field method is the easiest way to go about doing it. Handling the color change would be simple, just register for notifications for when the window resigns/becomes main and change the color appropriately.

from inappstorewindow.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.