【问题标题】:How to refresh browser view in finder window(mac os 10.5)?如何在查找器窗口中刷新浏览器视图(mac os 10.5)?
【发布时间】:2012-02-01 13:03:17
【问题描述】:

我想刷新 mac os 10.5 上 finder 的 NSBrowserView 中的所有 NSTableView。对于刷新图标视图、列表视图和流列表视图,我使用的是苹果脚本。

@"tell application \"Finder\" to update every item in front window"

在浏览器视图中,此脚本仅刷新最后一列。

例如,这个脚本只刷新第三列(icns-copy.m.....)。

谁能帮帮我?

【问题讨论】:

    标签: objective-c applescript macos-carbon finder appleevents


    【解决方案1】:

    它只刷新最后一列,因为每个 Finder 窗口一次只有一个目标文件夹(其内容显示在最后一列中)。解决方案是遍历文件夹层次结构并更新父文件夹。

    tell application "Finder"
        set t to front window's target
        repeat
            try
                update every item in t
                set t to t's parent -- go one level up
            on error                -- e.g. when you reach root
                exit repeat
            end try
        end repeat
    end tell
    

    这是一个快速的'n'dirty 解决方案,因为它一直上升到磁盘的根目录。理想情况下,它会停在最左边一列中显示的文件夹处,但我不知道如何确定它是哪个文件夹。

    【讨论】:

      【解决方案2】:
      tell application "Finder"
          set view to (get current view of front window as string)
          if view is equal to "column view" then
              set t to front window's target
              set p to folder "Myfolder" of folder "parag" of folder "Users" of startup disk as string
              repeat
                  if (t as string) begins with p then
                      try
                          update every item in t
                          set t to t's parent -- go one level up
                      on error -- e.g. when you reach root
                          exit repeat
                      end try
                  else
                      exit repeat
                  end if
              end repeat
          end if
      end tell
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2010-11-05
        • 1970-01-01
        • 2013-11-16
        • 1970-01-01
        相关资源
        最近更新 更多