Force NSOpenPanel's -panel:shouldShowFilename: to get called again?

  • In an NSOpenPanel, I want to force the open panel to re-check the
    "-panel:shouldShowFilename:" status on all the visible files. (In my
    accessory view, you can change options about what you want to open, and
    I want the open panel to honor any changes immediately.)

    I've done some Googling and some people have said that calling "[window
    update]" would cause this to happen, but it doesn't seem to be working
    for me in Leopard. Neither [window update] and [window display] seem to
    have any visible effect.

    If I go to the Finder and create a new file, this does force the Open
    panel to re-check everything. And of course if I browse to a different
    folder and then browse back, that also solves it. However neither of
    these tricks seems to be very useful :)

    Any ideas? Did this change in Leopard or is there some trick I'm missing?
  • On Jan 18, 2008 12:43 AM, John Stiles <JStiles...> wrote:

    > If I go to the Finder and create a new file, this does force the Open
    > panel to re-check everything.
    >
    > Any ideas?

    Have you tried NSWorkspace's noteFileSystemChanged:?

    Hamish
  • I hadn't tried it until now, but it didn't help :(
    I tried both
        NSString* directory = [panel directory];
        [[NSWorkspace sharedWorkspace] noteFileSystemChanged:directory];

    and the more generic
        [[NSWorkspace sharedWorkspace] noteFileSystemChanged];

    In the first case I also verified that "directory" was the path that I
    expected.
    Thanks for the help… any more ideas?

    Hamish Allan wrote:
    > On Jan 18, 2008 12:43 AM, John Stiles <JStiles...> wrote:
    >
    >
    >> If I go to the Finder and create a new file, this does force the Open
    >> panel to re-check everything.
    >>
    >> Any ideas?
    >>
    >
    > Have you tried NSWorkspace's noteFileSystemChanged:?
    >
    > Hamish
    >
  • On Jan 18, 2008 5:21 PM, John Stiles <JStiles...> wrote:

    > Thanks for the help… any more ideas?

    If Leopard Finder is monitoring the directory for changes using
    kqueue, perhaps creating and removing a .dotfile would work?

    Hamish
  • The plot thickens…

    I tried this and found that it works sometimes—depending on where the
    save panel is rooted!

    Up until now, I have always been doing tests on the desktop, and I am
    used to pressing "cmd+shift+D" in the save panel to make it warp to the
    desktop (rooting it there). In this mode, even creating a new file did
    not work to update the state of the existing, visible files. (A newly
    created file does appear, if its name doesn't start with a dot, and its
    enabled/disabled state is correct. But the already-visible files do not
    change their enabled state, even though it looks like the callback is
    being called.)

    However…! If I root the save panel elsewhere—for example, by choosing
    the hard drive icon from the left side of the save panel and then
    manually navigating to the Desktop folder, then things work differently!
    Creating a new file in this case/ does/ cause the existing files' state
    to be updated. (Unfortunately, telling the window's content view to do
    -setNeedsDisplay:YES did not cause the files' state to be updated.)

    This seems kind of broken to me. Maybe it's Radar time? Either way,
    though, I need to make it work now… I can't wait for 10.6 for this to be
    fixed :)

    Hamish Allan wrote:
    > On Jan 18, 2008 5:21 PM, John Stiles <JStiles...> wrote:
    >
    >
    >> Thanks for the help… any more ideas?
    >>
    >
    > If Leopard Finder is monitoring the directory for changes using
    > kqueue, perhaps creating and removing a .dotfile would work?
    >
    > Hamish
    >
  • On Jan 18, 2008 6:30 PM, John Stiles <JStiles...> wrote:

    > But the already-visible files do not change their enabled state,
    > even though it looks like the callback is being called.)

    The callback is called for the other files, but their visible state is
    not updated? Sounds like a bug to me!

    > This seems kind of broken to me. Maybe it's Radar time? Either way, though,
    > I need to make it work now… I can't wait for 10.6 for this to be fixed :)

    Clutching at straws... you could try sending orderOut followed by
    orderFront to the save panel?

    Hamish
  • Hamish Allan wrote:
    > On Jan 18, 2008 6:30 PM, John Stiles <JStiles...> wrote:
    >
    >
    >> But the already-visible files do not change their enabled state,
    >> even though it looks like the callback is being called.)
    >>
    >
    > The callback is called for the other files, but their visible state is
    > not updated? Sounds like a bug to me!
    >
    That's not the only fishy thing about this issue…

    >> This seems kind of broken to me. Maybe it's Radar time? Either way, though,
    >> I need to make it work now… I can't wait for 10.6 for this to be fixed :)
    >>
    >
    > Clutching at straws... you could try sending orderOut followed by
    > orderFront to the save panel?
    >
    Seems too extreme to me.
    Pfft... maybe I need to look for other apps which do this and try to
    figure out what they did. I know I can't be the only one that uses
    something like this.
  • On Jan 17, 2008, at 4:43 PM, John Stiles wrote:

    > In an NSOpenPanel, I want to force the open panel to re-check the "-
    > panel:shouldShowFilename:" status on all the visible files. (In my
    > accessory view, you can change options about what you want to open,
    > and I want the open panel to honor any changes immediately.)
    >
    > I've done some Googling and some people have said that calling
    > "[window update]" would cause this to happen, but it doesn't seem to
    > be working for me in Leopard. Neither [window update] and [window
    > display] seem to have any visible effect.
    >
    > If I go to the Finder and create a new file, this does force the
    > Open panel to re-check everything. And of course if I browse to a
    > different folder and then browse back, that also solves it. However
    > neither of these tricks seems to be very useful :)
    >
    > Any ideas? Did this change in Leopard or is there some trick I'm
    > missing?

    Yes, call -validateVisibleColumns. It is sort of expensive, so don't
    call it too frequently. If you want a cheaper version, please log a
    feature request.

    corbin
  • Jeez, and there it was staring me in the face the whole time.
    Honestly, I am only going to call it in response to user input, so I
    expect it will be good enough. Thank you so much for the pointer.
    (I'll post again if it doesn't actually work ;)  )

    Corbin Dunn wrote:
    > On Jan 17, 2008, at 4:43 PM, John Stiles wrote:
    >
    >> In an NSOpenPanel, I want to force the open panel to re-check the
    >> "-panel:shouldShowFilename:" status on all the visible files. (In my
    >> accessory view, you can change options about what you want to open,
    >> and I want the open panel to honor any changes immediately.)
    >>
    >> I've done some Googling and some people have said that calling
    >> "[window update]" would cause this to happen, but it doesn't seem to
    >> be working for me in Leopard. Neither [window update] and [window
    >> display] seem to have any visible effect.
    >>
    >> If I go to the Finder and create a new file, this does force the Open
    >> panel to re-check everything. And of course if I browse to a
    >> different folder and then browse back, that also solves it. However
    >> neither of these tricks seems to be very useful :)
    >>
    >> Any ideas? Did this change in Leopard or is there some trick I'm
    >> missing?
    >
    > Yes, call -validateVisibleColumns. It is sort of expensive, so don't
    > call it too frequently. If you want a cheaper version, please log a
    > feature request.
    >
    > corbin
  • Works like a charm!!! Whew! That's a lifesaver.

    John Stiles wrote:
    > Jeez, and there it was staring me in the face the whole time.
    > Honestly, I am only going to call it in response to user input, so I
    > expect it will be good enough. Thank you so much for the pointer.
    > (I'll post again if it doesn't actually work ;)  )
    >
    > Corbin Dunn wrote:
    >> On Jan 17, 2008, at 4:43 PM, John Stiles wrote:
    >>
    >>> In an NSOpenPanel, I want to force the open panel to re-check the
    >>> "-panel:shouldShowFilename:" status on all the visible files. (In my
    >>> accessory view, you can change options about what you want to open,
    >>> and I want the open panel to honor any changes immediately.)
    >>>
    >>> I've done some Googling and some people have said that calling
    >>> "[window update]" would cause this to happen, but it doesn't seem to
    >>> be working for me in Leopard. Neither [window update] and [window
    >>> display] seem to have any visible effect.
    >>>
    >>> If I go to the Finder and create a new file, this does force the
    >>> Open panel to re-check everything. And of course if I browse to a
    >>> different folder and then browse back, that also solves it. However
    >>> neither of these tricks seems to be very useful :)
    >>>
    >>> Any ideas? Did this change in Leopard or is there some trick I'm
    >>> missing?
    >>
    >> Yes, call -validateVisibleColumns. It is sort of expensive, so don't
    >> call it too frequently. If you want a cheaper version, please log a
    >> feature request.
    >>
    >> corbin

previous month january 2008 next month
MTWTFSS
  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      
Go to today