You can subscribe to this list here.
2002 |
Jan
(2) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(3) |
Oct
(3) |
Nov
|
Dec
(2) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(1) |
Feb
(11) |
Mar
(9) |
Apr
(1) |
May
(5) |
Jun
(5) |
Jul
(4) |
Aug
(3) |
Sep
(15) |
Oct
(8) |
Nov
(9) |
Dec
(11) |
2004 |
Jan
(5) |
Feb
(2) |
Mar
(1) |
Apr
(3) |
May
(6) |
Jun
(4) |
Jul
|
Aug
|
Sep
|
Oct
(9) |
Nov
|
Dec
(3) |
2005 |
Jan
(1) |
Feb
(7) |
Mar
(6) |
Apr
(36) |
May
(20) |
Jun
(42) |
Jul
(21) |
Aug
(12) |
Sep
(56) |
Oct
(5) |
Nov
(55) |
Dec
(53) |
2006 |
Jan
(43) |
Feb
(83) |
Mar
(98) |
Apr
(42) |
May
(68) |
Jun
(55) |
Jul
(50) |
Aug
(104) |
Sep
(13) |
Oct
(70) |
Nov
(37) |
Dec
(42) |
2007 |
Jan
(56) |
Feb
(18) |
Mar
(43) |
Apr
(80) |
May
(65) |
Jun
(149) |
Jul
(103) |
Aug
(71) |
Sep
(62) |
Oct
(67) |
Nov
(72) |
Dec
(63) |
2008 |
Jan
(64) |
Feb
(63) |
Mar
(31) |
Apr
(42) |
May
(71) |
Jun
(62) |
Jul
(37) |
Aug
(25) |
Sep
(5) |
Oct
(2) |
Nov
(7) |
Dec
(14) |
2009 |
Jan
(20) |
Feb
(15) |
Mar
(19) |
Apr
(8) |
May
(7) |
Jun
|
Jul
(37) |
Aug
(12) |
Sep
(19) |
Oct
(5) |
Nov
(1) |
Dec
(4) |
2010 |
Jan
(5) |
Feb
(24) |
Mar
(16) |
Apr
(9) |
May
(4) |
Jun
|
Jul
|
Aug
(6) |
Sep
(2) |
Oct
(1) |
Nov
|
Dec
|
2011 |
Jan
|
Feb
(1) |
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
(7) |
Sep
(1) |
Oct
|
Nov
|
Dec
|
2012 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
(6) |
Oct
|
Nov
|
Dec
|
2013 |
Jan
|
Feb
(1) |
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
(2) |
Nov
(1) |
Dec
|
2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
(2) |
Aug
(1) |
Sep
(2) |
Oct
|
Nov
(5) |
Dec
|
2016 |
Jan
|
Feb
(1) |
Mar
(1) |
Apr
|
May
(1) |
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2017 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2018 |
Jan
|
Feb
(1) |
Mar
(3) |
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
|
From: Jonathan P. <jp...@dc...> - 2006-02-01 22:39:41
|
On 1 Feb 2006, at 18:51, David wrote: > From my existing Cocoa app I would like to pass several NSArray's > to Ruby, manipulate them in Ruby, serialize the arrays in JSON > format, and return that data back to Cocoa. Does this seem like a > reasonable task for the RubyCocoa bridge? > > I see ruby 1.8+ has a to_yaml method for objects but how do I > produce JSON format for the arrays? Assuming you have an NSArray instance my_array in ruby, can you just do: manipulate(my_array.to_a).to_yaml i.e., convert the NSArray to a real ruby Array, do some stuff on it, then convert that array to yaml/json? |
From: David <dba...@gm...> - 2006-02-01 18:51:29
|
From my existing Cocoa app I would like to pass several NSArray's to Ruby, manipulate them in Ruby, serialize the arrays in JSON format, and return that data back to Cocoa. Does this seem like a reasonable task for the RubyCocoa bridge? I see ruby 1.8+ has a to_yaml method for objects but how do I produce JSON format for the arrays? |
From: Jonathan P. <jp...@dc...> - 2006-01-31 17:40:22
|
On 31 Jan 2006, at 17:26, David wrote: > I had came to this solution as well when testing and it does work. > I would have thought though that this could be encapsulated into an > RBObject class so that you can hide some of this and do some sanity > checks as well? There is a initWithRubyObject in RBObject but > would it be useful to have a initWithRubyObjectName? Can you give an example of how you'd like/expect things to work? I'm not quite clear on it yet. > I was also thinking that with XCode it should be possible to write > a script that will read your ruby files and generate an objc > interface file for them each time you build.. that would be cool.. Certainly possible - although how useful it is depends on how broad your interface is going to be. If there are relatively few entry points into ruby then it's probably easy enough to keep two files up to date (as you would have to do anyway with a plain objc header and implementation). Cheers, Jonathan |
From: David <dba...@gm...> - 2006-01-31 17:26:32
|
I had came to this solution as well when testing and it does work. I would have thought though that this could be encapsulated into an RBObject class so that you can hide some of this and do some sanity checks as well? There is a initWithRubyObject in RBObject but would it be useful to have a initWithRubyObjectName? I was also thinking that with XCode it should be possible to write a script that will read your ruby files and generate an objc interface file for them each time you build.. that would be cool.. > Another, possibly simpler, solution is to define an ObjC class in > Ruby: > > class Foo < OSX::NSObject > # ... > def myMethod(arg1) > puts arg1 > end > end > > Then, in objc: > > Class fooClass = NSClassFromString(@"Foo"); > id fooInstance = [[fooClass alloc] init]; > [fooInstance myMethod: @"hello"]; > [the above code is untested - I think the idea is right though] > > > > I imagine there'll be various compiler warnings since there are no > prototypes for the messages being sent to the 'id' variable type. > An objc interface declaration should fix that. > > > > Cheers, > > Jonathan > > |
From: David <dba...@gm...> - 2006-01-31 15:33:02
|
Thanks for the explanation.. I also spent some time investigating it =20= last night (probably because I'm stubborn :) ) and was able to come =20 to a similar result. I started an entry on the RubyCocoa Wiki so =20 that it will be easier for anybody in the future to not have to spend =20= time figuring out what to do.. Feel free to edit it or add this info =20= to your documentation.. The easier it is for a newby to get this stuff to work the more =20 people there will be using it. I originally tried getting PyObjc to =20 work and even asked on the mailing list but never got a =20 straightforward answer on how to make the bridge transparent.. =20 especially as transparent as the Ruby-Obj-C bridge appears to be.. :) =20= So now I'm using Ruby instead.. David On Jan 31, 2006, at 12:46 AM, Tim Burks wrote: > Hi David, > > Thanks for your comments on the documentation. > > I too have wanted to mix RubyCocoa into an existing application, but I > hadn't tried it until this evening, when I successfully converted one > of my pure Objective-C Cocoa projects to RubyCocoa. Here's my story: > > First I added the RubyCocoa framework to the project in Xcode. In my > case, I right-clicked on the project name in the Groups & Files panel > in Xcode, then selected Add->Existing Frameworks... and navigated to > /Library/Frameworks/RubyCocoa.framework. > > Next I replaced the contents of main.m with the following, taken from > the RubyCocoa Xcode templates: > --- > #import <RubyCocoa/RBRuntime.h> > > int main(int argc, const char *argv[]) > { > return RBApplicationMain("rb_main.rb", argc, argv); > } > --- > This is necessary to make sure that Ruby is properly initialized and > it also gives you a way to run some Ruby code when your program > starts. As far as I know, you *must* replace your main() to use > RubyCocoa, but you probably didn't have anything special there anyway > -- just a call to NSApplicationMain, which your converted app will > make with Ruby. > > Then I added rb_main.rb to my project using Add->Existing Files... and > then finding and selecting one from a template-based RubyCocoa > application. For reference, this short file contains the following > Ruby code: > --- > require 'osx/cocoa' > > def rb_main_init > path =3D OSX::NSBundle.mainBundle.resourcePath.to_s > rbfiles =3D Dir.entries(path).select {|x| /\.rb\z/ =3D~ x} > rbfiles -=3D [ File.basename(__FILE__) ] > rbfiles.each do |path| > require( File.basename(path) ) > OSX::NSLog "require #{File.basename(path)}" > end > end > > if $0 =3D=3D __FILE__ then > rb_main_init > OSX.NSApplicationMain(0, nil) > end > --- > It loads any ruby files in your application's resource directory and > then calls NSApplicationMain. > > Then I built and tested my application. Everything seemed to work > just as before, but now my formerly mild-mannered Objective-C program > can speak Ruby. > > =46rom here forward, you can add Ruby files to your application and = know > that all inline code in them will get executed when rb_main_init loads > the files during startup. > > In my case, I added a console object that I've been writing/debugging > that let's me run irb inside a Cocoa app. Accessing my Objective-C > objects was a puzzle at first, but I managed to get to my top-level > document object (a game) from the NSDocumentController: >> game_controller =3D = OSX::NSDocumentController.sharedDocumentController >> game =3D game_controller.documents.objectAtIndex(0) > > =46rom there, I could directly call the methods of my object from = Ruby: >> game.start >> game.sendEvent_forPlayer(10, 0) >> game.stop > > I'll test it more in the next few days, but as far as I can tell, the > transplant went smoothly. > > Hope that helps, > > Tim > > > ------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. Do you grep through =20 > log files > for problems? Stop! Download the new AJAX search engine that makes > searching your log files as easy as surfing the web. DOWNLOAD =20 > SPLUNK! > http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=103432&bid#0486&dat=121642= > _______________________________________________ > Rubycocoa-talk mailing list > Rub...@li... > https://lists.sourceforge.net/lists/listinfo/rubycocoa-talk |
From: kimura wataru<ki...@us...> - 2006-01-31 14:39:27
|
Hi, This patch was merged to CVS with small modification. I tested following code does not crash. Thanks! ----------- require 'osx/cocoa' class Ctrl < OSX::NSObject def applicationDidFinishLaunching(notification) win = Window.alloc.initWithContentRect([0, 0, 100, 100], :styleMask, OSX::NSTitledWindowMask + OSX::NSClosableWindowMask, :backing, OSX::NSBackingStoreBuffered, :defer, true) puts win.frame OSX::NSApplication.sharedApplication.terminate(self) end end class Window < OSX::NSWindow ns_overrides 'frame' def frame super_frame # => crash end end app = OSX::NSApplication.sharedApplication app.setDelegate(Ctrl.alloc.init) app.run ----------- Fri, Dec 23, 2005 11:11:37 AM, Jonathan Paisley wrote: >Hello, > >When using ns_overrides on methods that return large values (e.g., an >NSRect), a crash occurs since the native function implementation used >doesn't handle the msgSend_stret hidden first argument. > >The attached patch resolves this issue by choosing between one of two >implementations for the handle_ruby_method function. > >I haven't adjusted indentation in order to make the patch smaller and >clearer, so some cleanup may be required after application. > >Cheers, >Jonathan > -- kimura wataru |
From: Jonathan P. <jp...@dc...> - 2006-01-31 14:02:12
|
On 31 Jan 2006, at 6:46, Tim Burks wrote: >> game_controller = OSX::NSDocumentController.sharedDocumentController >> game = game_controller.documents.objectAtIndex(0) > > From there, I could directly call the methods of my object from Ruby: >> game.start >> game.sendEvent_forPlayer(10, 0) >> game.stop The same should work in the other direction too: assuming you can get a reference in objc to one of your ruby objects, you should be able to call methods on it. e.g.: In ruby: game.setRubyObject(someobj) Then in objc: [rubyObject someMethod: anArgument]; .. assuming you've got an instance variable called 'rubyObject' of type 'id' that has a setter method like: -(void)setRubyObject:(id)obj { [obj retain]; [rubyObject autorelease]; rubyObject = obj; } Another, possibly simpler, solution is to define an ObjC class in Ruby: class Foo < OSX::NSObject # ... def myMethod(arg1) puts arg1 end end Then, in objc: Class fooClass = NSClassFromString(@"Foo"); id fooInstance = [[fooClass alloc] init]; [fooInstance myMethod: @"hello"]; [the above code is untested - I think the idea is right though] I imagine there'll be various compiler warnings since there are no prototypes for the messages being sent to the 'id' variable type. An objc interface declaration should fix that. Cheers, Jonathan |
From: Tim B. <tim...@gm...> - 2006-01-31 06:46:15
|
Hi David, Thanks for your comments on the documentation. I too have wanted to mix RubyCocoa into an existing application, but I hadn't tried it until this evening, when I successfully converted one of my pure Objective-C Cocoa projects to RubyCocoa. Here's my story: First I added the RubyCocoa framework to the project in Xcode. In my case, I right-clicked on the project name in the Groups & Files panel in Xcode, then selected Add->Existing Frameworks... and navigated to /Library/Frameworks/RubyCocoa.framework. Next I replaced the contents of main.m with the following, taken from the RubyCocoa Xcode templates: --- #import <RubyCocoa/RBRuntime.h> int main(int argc, const char *argv[]) { return RBApplicationMain("rb_main.rb", argc, argv); } --- This is necessary to make sure that Ruby is properly initialized and it also gives you a way to run some Ruby code when your program starts. As far as I know, you *must* replace your main() to use RubyCocoa, but you probably didn't have anything special there anyway -- just a call to NSApplicationMain, which your converted app will make with Ruby. Then I added rb_main.rb to my project using Add->Existing Files... and then finding and selecting one from a template-based RubyCocoa application. For reference, this short file contains the following Ruby code: --- require 'osx/cocoa' def rb_main_init path =3D OSX::NSBundle.mainBundle.resourcePath.to_s rbfiles =3D Dir.entries(path).select {|x| /\.rb\z/ =3D~ x} rbfiles -=3D [ File.basename(__FILE__) ] rbfiles.each do |path| require( File.basename(path) ) OSX::NSLog "require #{File.basename(path)}" end end if $0 =3D=3D __FILE__ then rb_main_init OSX.NSApplicationMain(0, nil) end --- It loads any ruby files in your application's resource directory and then calls NSApplicationMain. Then I built and tested my application. Everything seemed to work just as before, but now my formerly mild-mannered Objective-C program can speak Ruby. From here forward, you can add Ruby files to your application and know that all inline code in them will get executed when rb_main_init loads the files during startup. In my case, I added a console object that I've been writing/debugging that let's me run irb inside a Cocoa app. Accessing my Objective-C objects was a puzzle at first, but I managed to get to my top-level document object (a game) from the NSDocumentController: > game_controller =3D OSX::NSDocumentController.sharedDocumentController > game =3D game_controller.documents.objectAtIndex(0) From there, I could directly call the methods of my object from Ruby: > game.start > game.sendEvent_forPlayer(10, 0) > game.stop I'll test it more in the next few days, but as far as I can tell, the transplant went smoothly. Hope that helps, Tim |
From: Brian M. <ma...@ex...> - 2006-01-31 04:54:38
|
On Jan 18, 2006, at 6:18 PM, Brian Marick wrote: > I want to put arbitrary ASCII strings onto the clipboard (including > NULs, control chars, etc.). I could do this: Here's the code. Thanks to Mark Hubbart for getting me started. (Note: I don't include OSX because I haven't explained that yet to the audience for this code.) require 'osx/cocoa' require 'test-strings/copy-util' MAC_OS_ROMAN_ENCODING=30 UTF8_ENCODING=4 def copy(string) copy_with_encoding(string, MAC_OS_ROMAN_ENCODING) true end #Example: unicopy %w{ 03b4 03d4 03a6 } def unicopy(hex_string_array) assert_names_of_acceptable_length(hex_string_array) copy_with_encoding(utf8(hex_string_array), UTF8_ENCODING) true end # Utilities def utf8(hex_string_array) number_array = hex_string_array.collect do | hex_name | hex_name.to_i(16) end number_array.pack("U*") end def copy_with_encoding(string, encoding) data = OSX::NSData.dataWithRubyString(string) ns_string = OSX::NSString.alloc.initWithData(data, :encoding, encoding) pb = OSX::NSPasteboard.generalPasteboard pb.declareTypes(["NSStringPboardType"], :owner, nil) pb.setString(ns_string, :forType, "NSStringPboardType") end ----- Brian Marick, independent consultant Mostly on agile methods with a testing slant www.exampler.com, www.testing.com/cgi-bin/blog Book in progress: www.exampler.com/book |
From: David <dba...@gm...> - 2006-01-30 17:47:36
|
Hello. I am looking into using Ruby to manipulate some data in my Cocoa-based application. I found the excellent documentation written by Tom Burks but it is not detailed enough on how to add this functionality to an existing Cocoa app in XCode. What I am looking for is the necessary changes needed to my project to allow my Cocoa app based on XCode 2.2 running on Tiger to call Ruby routines passing in NSArray objects with the minimum amount of changes to my project. I assume I need to at least add the RubyCocoa framework. After doing this and importing "RubyCocoa/RubyCocoa.h" I get an error: /Library/Frameworks/RubyCocoa.framework/Headers/osx_ruby.h:21:20: error: config.h: No such file or directory I also looked at the HybridLangApp sample but it is based on RBApplicationMain instead of NSApplicationMain. Thanks for any assistance. |
From: kimura wataru<ki...@us...> - 2006-01-30 13:41:27
|
Hi, I published a binary package of RubyCocoa 0.4.3d1(developer release). This package provideds RubyCocoa.framework and an extension libarary as universal binary. Developers of RubyCocoa (hisa and me) cannot test on intel Mac. Please tell us about running RubyCocoa on intel Mac. http://sourceforge.net/project/showfiles.php?group_id=44114&package_id=36578&release_id=389169 * RubyCocoa-0.4.3d1-OSX10.4universal.dmg (MD5:b12fddcfb0d4c15c2260d90492c97a30) = more information = * new config option --build-universal=yes/no * set CFLAGS "-isysroot" and "-arch ppc -arch i386" for universal binary * set LDFLAGS "-Wl,-isyslibroot" and "-arch ppc -arch i386" for universal binary * installer "postflight" script make a hardlink of rubycocoa.bundle to sitearchdir of ruby. Thanks, -- kimura wataru |
From: Jonathan P. <jp...@dc...> - 2006-01-27 13:00:14
|
On 25 Jan 2006, at 4:56, Aidan Rogers wrote: > Does anyone have any suggestions on how to obfuscate a RubyCocoa > application? I think the first question you need to answer is how secure does the obfuscation need to be? Somebody will always be able to (with some effort) extract the parse tree from the interpreter to see what's going on. There are different levels of obfuscation that might work. For example: * Hide the code in some form (like John's suggestion of a ZIP file) * Come up with a tool to reformat the code so it's hard to read. This might entail: removing line breaks, spaces etc (like in the obfuscated ruby contest) munging string literals so they're not easy to read e.g "hello" -> ("pkosd".unmunge) renaming local variables renaming methods * Compiling to native code somehow Renaming methods is tricky because of the dynamic nature of ruby - it's hard to catch all the bits that need to be renamed statically. Method calls on standard library and core objects will still be 'out in the open', unless you alias them all in some way. Would it be sufficient to distribute your application with licensing restrictions? Are you trying to stop people from seeing the code, modifying the application, redistributing it, ... ? Sorry I don't have any better suggestions at the moment. Once you know how secure it needs to be, it might be possible to come up with some more concrete ideas. Cheers, Jonathan |
From: Aidan R. <ai...@yo...> - 2006-01-26 16:20:14
|
Hi all, After the post a couple of weeks ago about building for universal, I decided to do the same. I checked out the latest CVS version and discovered that Kimura Wataru had already added support for this. I've built a binary, along with a universal ruby installer, and packaged it up if anyone is interested. http://www.infurious.com/blogs/index.php/aidan/2006/01/26/ ruby_and_rubycocoa_universal Aidan |
From: Steven R. <sro...@au...> - 2006-01-26 04:50:02
|
On Jan 25, 2006, at 10:44 PM, Aidan Rogers wrote: > Does anyone have any suggestions on how to obfuscate a RubyCocoa > application? Write it in Perl? <rim-shot> SR |
From: John L. <jo...@jo...> - 2006-01-25 17:43:14
|
On Jan 24, 2006, at 8:56 PM, Aidan Rogers wrote: > Does anyone have any suggestions on how to obfuscate a RubyCocoa > application? I've thought a little about this in the past, but haven't ever sat down and tried anything. What I've considered is creating a password-protected ZIP file from your Ruby source, and putting that in the Resources directory of your app bundle instead of the raw sources. Then, in rb_main.rb, open the ZIP file, extract each file to a Ruby string, and eval it. That should be the equivalent of the existing "require" loop. Obviously, "open the ZIP file" is the tricky part, since you don't want to hardcode the password in rb_main.rb. I could see an ObjC class that handles the ZIP reading (using some obfuscation on the password to hide it in the binary, like xor'ing with a secret number) and returning an NSString to rb_main, which could then be eval'ed. (I wouldn't claim that any of the above is "secure," but you didn't ask for security, you asked for obfuscation. ;) --John |
From: Aidan R. <ai...@ib...> - 2006-01-25 04:57:04
|
Hi all, Does anyone have any suggestions on how to obfuscate a RubyCocoa application? Aidan |
From: Dave H. <gr...@gr...> - 2006-01-21 10:24:45
|
On Jan 20, 2006, at 16:04, Neil Stevens wrote: > > You want something like this > > def alertDidEnd_returnCode_contextInfo(alert, code, info) > ... > end > > ... > selector = 'alertDidEnd:returnCode:contextInfo:' > > Note the colon at the end. And that was exactly the missing piece. Thanks! |
From: Neil S. <ne...@ha...> - 2006-01-21 00:04:23
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Dave Howell wrote: > Well, it's a string because I was trying to get the parameters to pass > properly, like > 'alertDidEnd_returnCode_contextInfo:returnCode:contextInfo" You want something like this def alertDidEnd_returnCode_contextInfo(alert, code, info) ... end ... selector = 'alertDidEnd:returnCode:contextInfo:' Note the colon at the end. - -- Neil Stevens - ne...@ha... "There is nothing patriotic about hating your country, or pretending that you can love your country but despise your government." -- William Jefferson Clinton -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (Darwin) iD8DBQFD0XqKf7mnligQOmERAheqAJsFtqHcVSK2RjHPOrWdr36p9mdCLgCghyV8 0sktiNi2WkueAieNGL04Q+4= =2PGI -----END PGP SIGNATURE----- |
From: Dave H. <gr...@gr...> - 2006-01-20 23:39:19
|
Whaddyaknow. I just ran across the same problem in a different context. @myTableView.setDoubleAction(no_known_way_to_set_this) setDoubleAction also requires a "selector", just like beginSheetModalForWindow. :/ |
From: Dave H. <gr...@gr...> - 2006-01-20 22:08:55
|
On Jan 20, 2006, at 13:11, Jonathan Paisley wrote: > On 20 Jan 2006, at 20:49, Dave Howell wrote: > >> def alertDidEnd_returnCode_contextInfo(theAlert) >> return >> end >> >> Unfortunately, I can't do anything but one-button messages, because I >> can't get the return code back from the NSAlert. The call to >> 'beginSheetModalForWindow...' looks like this in Objective-C: >> >> beginSheetModalForWindow:[someWindow window] >> modalDelegate:self >> didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) >> contextInfo:nil >> >> How exactly can I get a parameterized selector into this thing? In >> other words, how do I do >> @selector(alertDidEnd:returnCode:contextInfo:) >> in RubyCocoa? > > Is your callback method being called? Your ruby method: > > def alertDidEnd_returnCode_contextInfo(theAlert) > > doesn't have the right signature, because it's supposed to take three > arguments: > > def alertDidEnd_returnCode_contextInfo(theAlert,code,context) Not according to RubyCocoa. Like I said, the code as listed works "correctly." If I change my callback method to def alertDidEnd_returnCode_contextInfo(theAlert, returnCode, contextInfo) then the entire app blows apart: rb_main.rb:22: [BUG] Bus Error Any attempt to add a second parameter to the callback method causes that result. > Does using the 'code' argument there work? > > I think you can also use symbols for selectors (instead of strings) > e.g., :alertDidEnd_returnCode_contextInfo. Don't think it makes any > difference, just a matter of choice. Well, it's a string because I was trying to get the parameters to pass properly, like 'alertDidEnd_returnCode_contextInfo:returnCode:contextInfo" or "@selector(alertDidEnd:returnCode:contextInfo" But all such guesses failed one way or the other. |
From: Jonathan P. <jp...@dc...> - 2006-01-20 21:12:09
|
On 20 Jan 2006, at 20:49, Dave Howell wrote: > def alertDidEnd_returnCode_contextInfo(theAlert) > return > end > > Unfortunately, I can't do anything but one-button messages, because > I can't get the return code back from the NSAlert. The call to > 'beginSheetModalForWindow...' looks like this in Objective-C: > > beginSheetModalForWindow:[someWindow window] > modalDelegate:self > didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) > contextInfo:nil > > How exactly can I get a parameterized selector into this thing? In > other words, how do I do > @selector(alertDidEnd:returnCode:contextInfo:) > in RubyCocoa? Is your callback method being called? Your ruby method: def alertDidEnd_returnCode_contextInfo(theAlert) doesn't have the right signature, because it's supposed to take three arguments: def alertDidEnd_returnCode_contextInfo(theAlert,code,context) Does using the 'code' argument there work? I think you can also use symbols for selectors (instead of strings) e.g., :alertDidEnd_returnCode_contextInfo. Don't think it makes any difference, just a matter of choice. Hope that helps, Jonathan |
From: Dave H. <gr...@gr...> - 2006-01-20 20:49:56
|
I'm creating a handy way of doing alert sheets for a program, so that they'd work something like this: class Main < OSX::NSObject ib_outlet :window, def applicationDidFinishLaunching(something) myAlert = AlertMessage.alloc.init.display(@window, 'Quit already?', "This program just launched! Do you want to quit already?","OK","Cancel") if myAlert then @window.close end end Assume that the window's connected to "window" in InterfaceBuilder, et cetera. Unfortunately, there's one critical piece missing, and I'm mystified on how to get this part to work. The following code will run.... require 'osx/cocoa' class AlertMessage < OSX::NSObject include OSX def display(theWindow, messageTitle, messageText, defaultOption, altOption) p "Alert: " + messageTitle theAlert = NSAlert.alloc.init theAlert.addButtonWithTitle(defaultOption) theAlert.addButtonWithTitle(altOption) if altOption theAlert.setMessageText(messageTitle) theAlert.setInformativeText(messageText) someAnswer = theAlert.beginSheetModalForWindow_modalDelegate_didEndSelector_contextIn fo(theWindow, self, 'alertDidEnd_returnCode_contextInfo', nil) p "Answer" p someAnswer return @theResponse end def alertDidEnd_returnCode_contextInfo(theAlert) return end end Unfortunately, I can't do anything but one-button messages, because I can't get the return code back from the NSAlert. The call to 'beginSheetModalForWindow...' looks like this in Objective-C: beginSheetModalForWindow:[someWindow window] modalDelegate:self didEndSelector:@selector(alertDidEnd:returnCode:contextInfo:) contextInfo:nil How exactly can I get a parameterized selector into this thing? In other words, how do I do @selector(alertDidEnd:returnCode:contextInfo:) in RubyCocoa? |
From: Brian M. <ma...@ex...> - 2006-01-19 18:38:27
|
Sorry for the endless resendings of this mail. I wasn't getting copies, and I didn't see it in the web archive. I blush. On Jan 18, 2006, at 9:26 PM, Brian Marick wrote: ... ----- Brian Marick, independent consultant Mostly on agile methods with a testing slant www.exampler.com, www.testing.com/cgi-bin/blog Book in progress: www.exampler.com/book |
From: Brian M. <ma...@ex...> - 2006-01-19 03:26:36
|
I want to put arbitrary ASCII strings onto the clipboard (including NULs, control chars, etc.). I could do this: def copy(string) applescript = "set the clipboard to \"#{string}\"" OSX.do_osascript(applescript) true end But I see no way in applescript to quote peculiar characters (other than tab and newline). As a hack, I can convert the string into UTF-8, then back into a string, and paste that: def to_hex(string) string.unpack('c*').collect { | char | sprintf("%x", char)}.join end def copy(string) applescript=" set unicode_version to \xc7data utf8#{to_hex(string)}\xc8 set the clipboard to unicode_version as string " OSX.do_osascript(applescript) true end (The funny quoted characters are the chevrons applescript uses to surround unprintable stuff.) This happens to work even for Mac-Roman characters (those with the high-order bit set), though I think that's an unintended side-effect of the way "as string" works. I'd rather go through a lower-level API than through applescript, but I'm ignorant enough of OSA and other topics specific to the Mac that I can't find what that would look like. Can anyone help? ----- Brian Marick, independent consultant Mostly on agile methods with a testing slant www.exampler.com, www.testing.com/cgi-bin/blog Book in progress: www.exampler.com/book |
From: Mark H. <di...@ma...> - 2006-01-19 02:06:52
|
On Jan 18, 2006, at 4:18 PM, Brian Marick wrote: > I want to put arbitrary ASCII strings onto the clipboard (including > NULs, control chars, etc.). I could do this: > > [...] > > I'd rather go through a lower-level API than through applescript, > but I'm ignorant enough of OSA and other topics specific to the Mac > that I can't find what that would look like. > > Can anyone help? Assuming that you are wanting to use the rubycocoa framework for this, you should check out the NSPasteboard class: http://developer.apple.com/documentation/Cocoa/Reference/ ApplicationKit/ObjC_classic/Classes/NSPasteboard.html Code will look something like this: pb = OSX::NSPasteboard.generalPasteboard pb.setString str, :forType, "NSStringPboardType" Note, I have not tested this code, and it's been a while since I worked with the pasteboard in rubycocoa. This is just to get you started :) cheers, Mark |