I have had some good success in getting large chunks of my app done, but there are a few things that I can't seem to figure out, or at least get to working. I was able to figure out how to open up a new window that was based on a xib file, but what I really want to do is open the new window and close the current one which opened the new one. Also in the process of opening the new window I want to pass some data, at this point a single string. What is the best way to go about this? My lack of experience with cocoa, and by extension objective-c, is really killing me on figuring this out. Unfortuneatly there isn't just a simple close() method to call. Here is the code I am playing with to get this to work. Any help would be appreciated. https://gist.github.com/813803 Thanks Buddy --- Buddy Lindsey http://www.buddylindsey.com http://www.twitter.com/buddylindsey
On Sun, Feb 6, 2011 at 3:01 PM, Buddy Lindsey, Jr. <percent20@gmail.com> wrote:
I have had some good success in getting large chunks of my app done, but there are a few things that I can't seem to figure out, or at least get to working. I was able to figure out how to open up a new window that was based on a xib file, but what I really want to do is open the new window and close the current one which opened the new one. Also in the process of opening the new window I want to pass some data, at this point a single string. What is the best way to go about this? My lack of experience with cocoa, and by extension objective-c, is really killing me on figuring this out. Unfortuneatly there isn't just a simple close() method to call.
There actually is a simple close method, both on NSWindow[1] and NSWindowController[2]. Unless I'm misunderstanding, you should be able to proceed pretty much as you described. — Chuck [1]: http://developer.apple.com/library/mac/documentation/cocoa/reference/Applica... [2]: http://developer.apple.com/library/mac/documentation/Cocoa/Reference/Applica...
Okay, i think that makes sense. I guess need to figure out some way to get the reference to the current window that is open, so I can call the close method on it. Is that a correct approach? Also any ideas on passing data from one window to the other? --- Buddy Lindsey http://www.buddylindsey.com http://www.twitter.com/buddylindsey On Sun, Feb 6, 2011 at 8:49 PM, Charles Steinman <acharlieblue@gmail.com>wrote:
On Sun, Feb 6, 2011 at 3:01 PM, Buddy Lindsey, Jr. <percent20@gmail.com> wrote:
I have had some good success in getting large chunks of my app done, but there are a few things that I can't seem to figure out, or at least get to working. I was able to figure out how to open up a new window that was based on a xib file, but what I really want to do is open the new window and close the current one which opened the new one. Also in the process of opening the new window I want to pass some data, at this point a single string. What is the best way to go about this? My lack of experience with cocoa, and by extension objective-c, is really killing me on figuring this out. Unfortuneatly there isn't just a simple close() method to call.
There actually is a simple close method, both on NSWindow[1] and NSWindowController[2]. Unless I'm misunderstanding, you should be able to proceed pretty much as you described.
— Chuck
[1]: http://developer.apple.com/library/mac/documentation/cocoa/reference/Applica... [2]: http://developer.apple.com/library/mac/documentation/Cocoa/Reference/Applica... _______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Hello Buddy, On Sun, Feb 6, 2011 at 10:23 PM, Buddy Lindsey, Jr. <percent20@gmail.com>wrote:
Okay, i think that makes sense. I guess need to figure out some way to get the reference to the current window that is open, so I can call the close method on it.
Is that a correct approach?
Also any ideas on passing data from one window to the other?
Passing data between windows, is usually a mute point, as usually you wouldn't associate the data with the window, but with an class instance. The usual method I go about in setting up data storage, is to create a class, be it specific, or just a simple Struct class, that will store the data that I want referenced throughout the app, then create an instance stored as a constant, which would make it available no matter what class your dealing with. An example of this would be: # ProgInfo.rb require 'struct' ProgInfo = Struct.new(:info_a, :info_b, :info_c) GlobalProgInfo = ProgInfo.new # WindowControllerA.rb class MyWindowControllerA def some_event() GlobalProgInfo[:info_a] = "This is a dummy string" GlobalProgInfo[:info_b] = 32 GlobalProgInfo[:info_c] = "Yet another dummy string" -- Open Window code to open up your next xib instance. do_window_b_open() self.close() end end # WindowControllerB.rb class MyWindowControllerB def some_other_event() some_text_edit.setStringValue(GlobalProgInfo[:info_a]) end end This of course is some mock code, but it gives you the general idea of what you should follow, to make it work. And I am sure, this is but one of many different ways in which you can pass data between instances. hth, Mario
--- Buddy Lindsey http://www.buddylindsey.com http://www.twitter.com/buddylindsey
On Sun, Feb 6, 2011 at 8:49 PM, Charles Steinman <acharlieblue@gmail.com>wrote:
On Sun, Feb 6, 2011 at 3:01 PM, Buddy Lindsey, Jr. <percent20@gmail.com> wrote:
I have had some good success in getting large chunks of my app done, but there are a few things that I can't seem to figure out, or at least get to working. I was able to figure out how to open up a new window that was based on a xib file, but what I really want to do is open the new window and close the current one which opened the new one. Also in the process of opening the new window I want to pass some data, at this point a single string. What is the best way to go about this? My lack of experience with cocoa, and by extension objective-c, is really killing me on figuring this out. Unfortuneatly there isn't just a simple close() method to call.
There actually is a simple close method, both on NSWindow[1] and NSWindowController[2]. Unless I'm misunderstanding, you should be able to proceed pretty much as you described.
— Chuck
[1]: http://developer.apple.com/library/mac/documentation/cocoa/reference/Applica... [2]: http://developer.apple.com/library/mac/documentation/Cocoa/Reference/Applica... _______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
-- Mario Steele Lieutenant Commander 3 XO - Geo 99 XO - STO IFT Fleet http://www.trekfederation.com http://geo99.ruby-im.net
participants (3)
-
Buddy Lindsey, Jr.
-
Charles Steinman
-
Mario Steele