Hi All, First post, so a little bit about me: I am a SW engineer and have been one for over 20 years, increadible as that may sound. I have programmed on the Mac before in Ada95, Obj-C and Java (but I have had a pause of about 5 years from the Mac). Now that MacRuby seems to gain some foothold I'd like to get back to the mac and make the jump from Obj-C to MacRuby. I work in Xcode, and have just started a new MacRuby Core-Data Application. The first goings look good, but in implementing my first window controller I ran into a (little?) problem: I cannot get the state of a checkbox: status = @myCheckbox.state always returns a Fixnum with value 0. regardless of the visual representation of the checkbox (i.e. selected or not) The checkbox should be mapped correctly because: myTitle = @myCheckbox.title does indeed give me the title I set in the IB. I checked the archives but did not find any discussions about this. There was something about checkboxes and hotcocoa, but I do not use hotcocoa. The best solution would be a simple stupid mistake on my part :-) Any takers? Regards, Rien.
Hi Marinus / Rien, I just did a quick test, given a nib with window and a controller ruby file. 1. I dragged a checkbox NSButton onto the window 2. i created an attr_accessor :check in my controller 3. I created a method called test_check in my controller: def test_check(sender) p @check.state end 4. I linked @check and the test_check method to the checkbox And when i click on an off the checkbox the state toggles between 0 and 1. So I do not think it is an issue MacRuby - could you try something simple like the above? How were you polling the check box state? That is: which method is status = @myCheckbox.state in? Perhaps this method is not being called. Cheers, John On Jul 8, 2009, at 15:06 , Marinus van der Lugt wrote:
Hi All,
First post, so a little bit about me: I am a SW engineer and have been one for over 20 years, increadible as that may sound. I have programmed on the Mac before in Ada95, Obj-C and Java (but I have had a pause of about 5 years from the Mac). Now that MacRuby seems to gain some foothold I'd like to get back to the mac and make the jump from Obj-C to MacRuby.
I work in Xcode, and have just started a new MacRuby Core-Data Application.
The first goings look good, but in implementing my first window controller I ran into a (little?) problem: I cannot get the state of a checkbox:
status = @myCheckbox.state
always returns a Fixnum with value 0. regardless of the visual representation of the checkbox (i.e. selected or not)
The checkbox should be mapped correctly because:
myTitle = @myCheckbox.title
does indeed give me the title I set in the IB. I checked the archives but did not find any discussions about this. There was something about checkboxes and hotcocoa, but I do not use hotcocoa.
The best solution would be a simple stupid mistake on my part :-)
Any takers?
Regards, Rien.
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Thanks John, Yes the simple example works OK. My controller looks like this: class DisclaimerController < NSWindowController attr_accessor :showAgain def exitButtonAction(sender) NSLog("Disclaimer Window: exit button clicked") end def startButtonAction(sender) NSLog("Disclaimer Window: start button clicked") end def toggleShowAgainAction(sender) NSLog("Disclaimer Window: toggle checkbox clicked") p @showAgain.state p @showAgain.title active = (@showAgain.state == NSOnState) if (active) then NSLog("Disclaimer Window: toggle switched to Selected") else NSLog("Disclaimer Window: toggle switched to Unselected") end end end And the output looks like this: 2009-07-08 18:47:08.324 xxxx[610:10b] Disclaimer NIB loaded 2009-07-08 18:47:10.658 xxxx[610:10b] Disclaimer Window: toggle checkbox clicked 0 "Do not show this warning again." 2009-07-08 18:47:10.659 xxxx[610:10b] Disclaimer Window: toggle switched to Unselected 2009-07-08 18:47:11.570 xxxx[610:10b] Disclaimer Window: toggle checkbox clicked 0 "Do not show this warning again." 2009-07-08 18:47:11.571 xxxx[610:10b] Disclaimer Window: toggle switched to Unselected 2009-07-08 18:47:12.690 xxxx[610:10b] Disclaimer Window: toggle checkbox clicked As you can see the "toggleShowAgainAction" is activated, and the checkbox is linked to "showAgain". PS: The checkbox has the title "Do not show this warning again." (Sometimes I wish I had chosen a different profession, VBG!) Regards, Rien. On Jul 8, 2009, at 3:28, John Shea wrote:
Hi Marinus / Rien,
I just did a quick test, given a nib with window and a controller ruby file.
1. I dragged a checkbox NSButton onto the window 2. i created an attr_accessor :check in my controller 3. I created a method called test_check in my controller:
def test_check(sender) p @check.state end
4. I linked @check and the test_check method to the checkbox
And when i click on an off the checkbox the state toggles between 0 and 1.
So I do not think it is an issue MacRuby - could you try something simple like the above?
How were you polling the check box state? That is: which method is status = @myCheckbox.state in? Perhaps this method is not being called.
Cheers, John
On Jul 8, 2009, at 15:06 , Marinus van der Lugt wrote:
Hi All,
First post, so a little bit about me: I am a SW engineer and have been one for over 20 years, increadible as that may sound. I have programmed on the Mac before in Ada95, Obj-C and Java (but I have had a pause of about 5 years from the Mac). Now that MacRuby seems to gain some foothold I'd like to get back to the mac and make the jump from Obj-C to MacRuby.
I work in Xcode, and have just started a new MacRuby Core-Data Application.
The first goings look good, but in implementing my first window controller I ran into a (little?) problem: I cannot get the state of a checkbox:
status = @myCheckbox.state
always returns a Fixnum with value 0. regardless of the visual representation of the checkbox (i.e. selected or not)
The checkbox should be mapped correctly because:
myTitle = @myCheckbox.title
does indeed give me the title I set in the IB. I checked the archives but did not find any discussions about this. There was something about checkboxes and hotcocoa, but I do not use hotcocoa.
The best solution would be a simple stupid mistake on my part :-)
Any takers?
Regards, Rien.
_______________________________________________ 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
I am getting rather desperate here :-( The initWithWindowNibName suddenly stopped working. It still works in a previous xcode project that I had, but I cannot create new MacRuby projects that use this method. Is there something scr*d-up on my machine? I am still on the checkbox problem and created an Obj-C xcode project that shows the correct working of the "state" operation. Then I created an exact copy (translation) in an xcode MacRuby project and now the initWithWindowNibName suddenly does not work anymore. I checked and double checked and triple checked all the usual caveats. Nothing. Has anybody here ever had something like this before? (and what was the solution?) Regards, Rien.
Hi Marinus, Are you by any chance trying to run a RubyCocoa project (of parts of it) with MacRuby? Both projects use a different syntax and are therefore incompatible. You should be able to use initWithWindowNibName in both RubyCocoa and MacRuby projects. In case it does not work for you, please send us a code snippet or a simple xcode project that reproduces the problem for you and we will have a look at it. Laurent On Jul 8, 2009, at 1:35 PM, Marinus van der Lugt wrote:
I am getting rather desperate here :-(
The initWithWindowNibName suddenly stopped working. It still works in a previous xcode project that I had, but I cannot create new MacRuby projects that use this method.
Is there something scr*d-up on my machine?
I am still on the checkbox problem and created an Obj-C xcode project that shows the correct working of the "state" operation. Then I created an exact copy (translation) in an xcode MacRuby project and now the initWithWindowNibName suddenly does not work anymore.
I checked and double checked and triple checked all the usual caveats. Nothing.
Has anybody here ever had something like this before? (and what was the solution?)
Regards, Rien. _______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Sorry, forgot to add that you will need to uncomment the "applicationDidFinishLaunching" method in AppDelegate. Otherwise the project runs just fine. Regards, Rien. On Jul 8, 2009, at 10:59, Laurent Sansonetti wrote:
Hi Marinus,
Are you by any chance trying to run a RubyCocoa project (of parts of it) with MacRuby? Both projects use a different syntax and are therefore incompatible.
You should be able to use initWithWindowNibName in both RubyCocoa and MacRuby projects.
In case it does not work for you, please send us a code snippet or a simple xcode project that reproduces the problem for you and we will have a look at it.
Laurent
On Jul 8, 2009, at 1:35 PM, Marinus van der Lugt wrote:
I am getting rather desperate here :-(
The initWithWindowNibName suddenly stopped working. It still works in a previous xcode project that I had, but I cannot create new MacRuby projects that use this method.
Is there something scr*d-up on my machine?
I am still on the checkbox problem and created an Obj-C xcode project that shows the correct working of the "state" operation. Then I created an exact copy (translation) in an xcode MacRuby project and now the initWithWindowNibName suddenly does not work anymore.
I checked and double checked and triple checked all the usual caveats. Nothing.
Has anybody here ever had something like this before? (and what was the solution?)
Regards, Rien. _______________________________________________ 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
participants (3)
-
John Shea
-
Laurent Sansonetti
-
Marinus van der Lugt