Professional Web Applications Themes

Problem it Panelwindow - Mac Programming

Hello, I have a problem which is difficult to describe. I will do my very best ;-) I have a doc-based cocoa-application. Then I have a mainwindowcontroller. This controller is used the common way: In MyDoent.h I have - (void)makeWindowControllers { MainWndCtrl *mainWndCtrl = [[MainWndCtrl alloc] init]; [self addWindowController:mainWndCtrl]; [mainWndCtrl release]; } Okay, everything works. Now I want to have a info window (like in graphikconverter - the info-panel with the size of the image and so on) attached to its own mainwindow. So I created a nib-file with a NSPanel and created a InfoWndController. The info-panel is shown in ...

  1. #1

    Default Problem it Panelwindow

    Hello,

    I have a problem which is difficult to describe. I will do my very best
    ;-)

    I have a doc-based cocoa-application.

    Then I have a mainwindowcontroller. This controller is used the common
    way: In MyDoent.h I have

    - (void)makeWindowControllers
    {
    MainWndCtrl *mainWndCtrl = [[MainWndCtrl alloc] init];
    [self addWindowController:mainWndCtrl];
    [mainWndCtrl release];
    }

    Okay, everything works.

    Now I want to have a info window (like in graphikconverter - the
    info-panel with the size of the image and so on) attached to its own
    mainwindow.

    So I created a nib-file with a NSPanel and created a InfoWndController.
    The info-panel is shown in a function in the mainwindowcontroller:

    -(IBAction)showHistogrammWnd:(id)sender
    {
    if(!myHistoWndCtrl) {
    myHistoWndCtrl = [[HistoWndCtrl alloc] init];

    //for having a [self doent]
    [[self doent] addWindowController:myHistoWndCtrl];
    [myHistoWndCtrl release];

    }
    [myHistoWndCtrl showWindow:self];

    [[self doent]updateAllViews:NO];
    }

    (in the info-panel i want to access the doent).

    Okay the problem is that the info-panel is still visible when the
    associated mainwindow lost the control. That means when the focus
    switches from one open doent to an other the info panel stays the
    same. I want that it hides when its mainwindow lost the focus and that
    its show when the mainwindow gets the focus.

    How is the right mechanism to have a NSPanel (or something like that)
    associated to a doent-window?

    Thanks - Robert.


    Robert Guest

  2. #2

    Default Re: Problem it Panelwindow

    Robert W. Kuhn <de> wrote:
     

    One obvious way is to hide the panel when the window loses its Main
    status. The window delegate knows when this happens. See the
    doentation on NSWindow. m.

    --
    matt neuburg, phd = com, http://www.tidbits.com/matt/
    AppleScript: The Definitive Guide
    http://www.amazon.com/exec/obidos/ASIN/0596005571/somethingsbymatt
    Read TidBITS! It's free and smart. http://www.tidbits.com
    matt Guest

  3. #3

    Default Re: Problem it Panelwindow

    matt neuburg <com> wrote:
     
    >
    > One obvious way is to hide the panel when the window loses its Main
    > status. The window delegate knows when this happens. See the
    > doentation on NSWindow.[/ref]

    - (void)windowDidBecomeKey:(NSNotification *)aNotification
    - (void)windowDidResignKey:(NSNotification *)aNotification

    Fine :-) Thanks.

    But ho do I get the information if a window is visible and how do I hide
    or activate the window. I do have the WindowController.

    Is there something like
    [windowCtrl isVisible]
    and something like
    [windowCtrl hide]
    [windowCtrl show]

    Thanks.
    Robert Guest

  4. #4

    Default Re: Problem it Panelwindow

    Robert W. Kuhn <de> wrote:
     

    I did it that way:
    (myHistoWndCtrl ist the controller of the panel)

    #pragma mark DELEGATES
    - (void)windowDidResignKey:(NSNotification *)aNotification
    {
    mybHistoWndWasVisible = [[myHistoWndCtrl window] isVisible];
    [myHistoWndCtrl release];
    // [[myHistoWndCtrl window] setIsVisible:NO];

    NSLog("windowDidResignKey (visible:%)", mybHistoWndWasVisible);
    }

    - (void)windowDidBecomeKey:(NSNotification *)aNotification
    {
    if(mybHistoWndWasVisible) {
    [self showHistogrammWnd:self];
    // [[myHistoWndCtrl window] setIsVisible:YES];
    // [myHistoWndCtrl showWindow:self];
    }

    NSLog("windowDidBecomeKey (visible%:)", mybHistoWndWasVisible);
    }

    But I get a bus error and the or the Panel flickers when its mainwndctrl
    windowDidBecomeKey. What's the right way?
    Robert Guest

  5. #5

    Default Re: Problem it Panelwindow

    Robert W. Kuhn <de> wrote:
     

    Ouch.

    file:///Developer/Doentation/Cocoa/Conceptual/WinPanel/Tasks/OpeningC
    losingWindows.html

    m.

    --
    matt neuburg, phd = com, http://www.tidbits.com/matt/
    AppleScript: The Definitive Guide
    http://www.amazon.com/exec/obidos/ASIN/0596005571/somethingsbymatt
    Read TidBITS! It's free and smart. http://www.tidbits.com
    matt Guest

  6. #6

    Default Re: Problem it Panelwindow

    matt neuburg <com> wrote:
     
    >
    > file:///Developer/Doentation/Cocoa/Conceptual/WinPanel/Tasks/OpeningC
    > losingWindows.html[/ref]

    Thanks. Now I do it this way and it works :-)

    #pragma mark DELEGATES
    - (void)windowDidResignKey:(NSNotification *)aNotification
    {
    if(!myHistoWndCtrl)
    return;

    mybHistoWndWasVisible = [[myHistoWndCtrl window] isVisible];

    [[myHistoWndCtrl window] orderOut:self];
    }

    - (void)windowDidBecomeKey:(NSNotification *)aNotification
    {
    if(mybHistoWndWasVisible && myHistoWndCtrl) {
    [[myHistoWndCtrl window] orderFront:self];
    }
    }

    One think: I start the panel after clicking a menuitem from the
    mainwindowcontroller:

    -(IBAction)showHistogrammWnd:(id)sender
    {
    if(!myHistoWndCtrl) {
    myHistoWndCtrl = [[HistoWndCtrl alloc] init];
    [myHistoWndCtrl setDoent:[self doent]];
    }
    [myHistoWndCtrl showWindow:self];

    [[self doent]updateAllViews:NO];
    }

    The problem was that I did not get the "Doent has changed. Do you
    want to save it?"-Alertpanel. I solved it this way:
    In the delegate of the mainwndcontroller I do a

    - (void)windowWillClose:(NSNotification *)aNotification
    {
    [[myHistoWndCtrl window] performClose:self];
    [myHistoWndCtrl release];
    }

    Is this okay?
    Robert Guest

  7. #7

    Default Re: Problem it Panelwindow

    Robert W. Kuhn <de> wrote:
     

    No. I get an SIGSEV :-(
    With
    [myHistoWndCtrl setDoent:[self doent]];
    I get the "Doent has changed. Do you want to save it?"-Alertpanel
    I changed the code that now I do nothing in windowWillClose. But then I
    get a sigsev when I close the application:

    2004-02-22 12:28:15.002 iVignette[1803] *** -[NSCFDictionary
    removeWindowController:]: selector not recognized
    2004-02-22 12:28:15.003 iVignette[1803] Exception raised during posting
    of notification. Ignored. exception: *** -[NSCFDictionary
    removeWindowController:]: selector not recognized

    What can I do?
    Robert Guest

Similar Threads

  1. contribute problem - access denied file may not existpermission problem
    By Al1973 in forum Macromedia Contribute Connection Administrtion
    Replies: 6
    Last Post: September 17th, 04:16 PM
  2. Replies: 2
    Last Post: September 30th, 12:13 PM
  3. Replies: 0
    Last Post: August 2nd, 03:03 PM
  4. Replies: 2
    Last Post: July 17th, 07:27 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139