RubyCocoa Sheets - help anyone?

T

Tim Perrett

Hey Guys

Just wondered if somone could help me with using modal sheets in
RubyCocoa - I think I am nearly there but its one method paramater that
is sucuppering me.... In the apple tutorial here is the code:


- (void)showCustomSheet: (NSWindow *)window

// User has asked to see the custom display. Display it.
{
if (!myCustomSheet)
//Check the myCustomSheet instance variable to make sure the custom
sheet does not already exist.
[NSBundle loadNibNamed: @"MyCustomSheet" owner: self];

[NSApp beginSheet: myCustomSheet
modalForWindow: window
modalDelegate: self
didEndSelector:
@selector(didEndSheet:returnCode:contextInfo:)
contextInfo: nil];

// Sheet is up here.
// Return processing to the event loop
}



So I have translated this into

def showConnectionSheet(window)
NSBundle.loadNibNamed_owner('Connection', self)
NSApp.beginSheet_modalForWindow_modalDelegate_didEndSelector_contextInfo(@connection,
self.window, nil, nil, nil)
end


But its the didEndSelector paramater that I do not know what to put in?
Can anyone help me?

Cheers

Tim
 
L

Logan Capaldo

Hey Jacob

Excuse my ignorence but I am not sure how that would help me? I dont
actually understand what the
@selector(didEndSheet:returnCode:contextInfo:) code is actually doing -
could you perhaps explain? If I can understand what it does i should be
able to translate it hopefully.
@selector is a way of reifying a method name. it's a bit like using
:a_method_name in ruby or method:)method_name). Basically the sheet
wants the name of a method to run when the sheet is done interacting
with the user.
 
J

John Joyce

Hey Jacob

Excuse my ignorence but I am not sure how that would help me? I dont
actually understand what the
@selector(didEndSheet:returnCode:contextInfo:) code is actually
doing -
could you perhaps explain? If I can understand what it does i
should be
able to translate it hopefully.

Cheers

Tim
For Cocoa info you might try the CocoaDev list.
http://lists.apple.com
RubyCocoa is Ruby, but the references on Cocoa are all in Objective-C
and yes they can be a bit vague. It's a huge framework.
 
T

Tim Perrett

Ok cool, that makes sense, so I would need to define a sheet method that
runs just before the sheet is going to close? Its a callback for the
sheet effectivly then.

I have tried instansiating both NSSelector and NSSelectorFromString, but
no luck. I have tried instansiating them in a number of ways:

NSSelectorFromString.alloc.init('connectionSheetDidEnd')
NSSelector('connectionSheetDidEnd').alloc.init

and so on...

It complains it does not like the NSSelectorFromString and thinks it is
an uninitilized constant?

Cheers

Tim
 
L

Logan Capaldo

Ok cool, that makes sense, so I would need to define a sheet method that
runs just before the sheet is going to close? Its a callback for the
sheet effectivly then.

I have tried instansiating both NSSelector and NSSelectorFromString, but
no luck. I have tried instansiating them in a number of ways:

NSSelectorFromString.alloc.init('connectionSheetDidEnd')
NSSelector('connectionSheetDidEnd').alloc.init

and so on...

It complains it does not like the NSSelectorFromString and thinks it is
an uninitilized constant?
IIRC NSSelectorFromString is a good old fashioned C function, not a
class. *checks to be sure*
Yep: http://developer.apple.com/document....html#//apple_ref/c/func/NSSelectorFromString
 
T

Tim Perrett

IIRC NSSelectorFromString is a good old fashioned C function, not a
class. *checks to be sure*
Yep:

So if its a C function, what does that mean for me using RubyCocoa? its
in the foundation framework so i would have thought I could use it with
the ruby bridge?

Thanks

Tim
 
J

John Joyce

So if its a C function, what does that mean for me using RubyCocoa?
its
in the foundation framework so i would have thought I could use it
with
the ruby bridge?

Thanks

Tim
That's not necessarily a problem.
Remember that Cocoa's main language is Objective-C which is a strict
super-set of C. Valid C is valid Objective-C.
RubyCocoa is a bridge to Cocoa.
I haven't used it myself. Cocoa is so big already with lots of vague
docs. It's going to be tough but fun going with RubyCocoa perhaps.
You might want to get the Hillegass book on Cocoa first if you
haven't got it already. If you know what's going on in Cocoa with Obj-
C, then Ruby Cocoa will be a lot easier.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,241
Messages
2,571,223
Members
47,856
Latest member
mmorais

Latest Threads

Top