|
From: kimura w. <ki...@us...> - 2005-04-14 15:14:44
|
Thanks,
I see that you said.
RubyCocoa apps with ruby threads normarlly work fine, like SimpleApp.app
in examples. But in this case, calling NSApplication#endSheet fails.
I found NSApplication#endSheet succeeded when the method was invoked with
new NSThread. I guess a sheet expects to receive "endSheet:" from other
run-loop.
app = OSX.NSApp
app.beginSheet(@sheet, ...)
Thread.start do
<<some procedure>>
# send NSApplication#endSheet to new NSThread
OSX::NSThread.detachNewThreadSelector('endSheet:',
:toTarget, app, :withObject, @sheet)
end
Wed, 13 Apr 2005 18:46:59 +0100, Jonathan Paisley wrote:
>On 13 Apr 2005, at 18:20, kimura wataru wrote:
>
>The problem is that the lengthy processing (in your example the 1..3
>sleep loop) doesn't allow for any GUI events to be processed. The run
>loop is suspended (handling our click event) until the ruby method
>returns. I don't want the GUI to lock up like this.
>
>What I wanted to be able to do was:
>
>def buttonHandler(sender)
> ...beginSheet(...)
> Thread.new do
> <<lengthy processing>>
> ...orderOut(...)
> ...endSheet(...)
> end
>end
>
>This fails (sometimes) because calling the Cocoa methods (orderOut,
>endSheet) from the non-main Ruby thread is unsafe.
>
|