2011年11月7日月曜日

NSProgressIndicator on Sheet

NSProgressIndicator をシート上で動かそうとしたときに動きませんでした。

This method runs the modal event loop for the specified sheet synchronously. It displays the sheet, makes it key, starts the run loop, and processes events for it. While the application is in the run loop, it does not respond to any other events (including mouse, keyboard, or window-close events) unless they are associated with the sheet. It also does not perform any tasks (such as firing timers) that are not associated with the modal run loop. In other words, this method consumes only enough CPU time to process events and dispatch them to the action methods associated with the modal window.

このメソッドは指定されたシートのためのモーダル・イベント・ループを同期的に実行します。表示するシートをキーウィンドウにして、実行ループを開始します。そして、そのためのイベントを処理します。アプリケーションが実行ループ中のあいだ、シートに関連付けされてない限り、他のどんなイベント(マウス、キーボード、またはウィンドウ-クローズ・イベントを含む)にも応答しません。また、モーダル実行ループに関連付けられていないどんな(タイマー発動のような)タスクも実行しません。つまり、このメソッドはイベントを処理するために必要なCPU時間を費し、それらをモーダル・ウィンドウに関連付けられたアクション・メソッドへ送ります。

ということで、シート上のインジケータの更新を反映させるには、
    for (NSInteger index = 0; index < 1000; index++) {

        [indicator incrementBy:1.0];
        [indicator displayIfNeeded];
        
    }
ウィンドウとかビューとかに直接 display* を送信してやります。

0 件のコメント:

コメントを投稿