Hi all,

I'm trying to build a simple Cocoa GUI that acts as an observer to my Ruby text application and reports progress in a window (with a progress bar, etc).

I'm using RubyCocoa for creating the GUI, but I guess anyone who does not know Ruby or RubyCocoa might be still able to answer my question.

My problem is that I need to run the following GUI in a separate thread and be able to send messages to it from my main app.

Can anyone point how to do this? I've tried wrapping the app instantiation in a NSObject and doing NSThread.detachNewThreadSelector_toTarget_withObject(:run, runner, nil) to it, but the window does not appear.

Thanks.

--------------------------------

require 'osx/cocoa'
include OSX


class AppDelegate < NSObject
  def init
    frame = [200.0, 300.0, 250.0, 100.0]
@win = NSWindow.alloc.initWithContentRect_styleMask_backing_defer(frame, 15, 2, 0)
    @win.setTitle 'Test'
    @win.setLevel 0
@bar = NSProgressIndicator.alloc.initWithFrame [10.0, 10.0, 80.0, 80.0]
    @win.contentView.addSubview(@bar)
    @bar.setIndeterminate(false)
    @win.display
    @win.orderFrontRegardless
  end

  def step
    @bar.incrementBy(20)
  end
end


app = NSApplication.sharedApplication
app.setDelegate(AppDelegate.alloc.init)
app.run
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to