[MacRuby-devel] HotCocoa table_view and the doubleAction

2009-04-01 Thread Dave Baldwin
I am having some difficulty on getting the double click action to work  
with a table view.  I have code along the lines of:



@tableView = table_view(
:columns => [column(:id => :item, :title 
=> '')],
:data => @filteredData
)


@tableView.doubleAction = 'doubleClickInRow:'

def @tableView.doubleClickInRow (sender)
NSLog "in double click"
end

When I run and double click on a row in the table I get:

*** -[RBAnonymous132 doubleClickInRow:]: unrecognized selector sent to  
instance 0x8005d1c40



Does anyone know how to get this to work?

Thanks,

Dave.
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


Re: [MacRuby-devel] HotCocoa table_view and the doubleAction

2009-04-01 Thread John Shea

Hi Dave,

I am actually wrestling with a similar problem.

 I believe I have solved your problem, maybe you can solve mine ;-) ??

in the start method I placed:
  @my_table_view.setTarget(self)
  @my_table_view.setDoubleAction(:double)


and then later on a method:

  def double
NSLog ("double")
  end


My issue is also delegating table updates to certain methods.

I noticed that tableview.setDelegate(self) did not do anything - and  
then I assumed that the TableDataSource is actually handling the  
delegate  - confirmed when I changed the numberOfRowsInTableView  
method to return the value 1.


But then I assume that I am not supposed to add my own tableView(tv,  
setObjectValue:anObject, forTableColumn:col, row:row) method to the  
HotCocoa TableDataSource file?


What happens if I have two tables in the one application with  
different delegated behaviour?


Am I supposed to get funky and add the different versions of the  
tableView methods to the data instance itself?
Is there a way to override the delegate dispatch to actually go a  
local class?


or do I setActions like in the double clicked example above?

Cheers and thanks,
J







On Apr 1, 2009, at 11:33 , Dave Baldwin wrote:

I am having some difficulty on getting the double click action to  
work with a table view.  I have code along the lines of:



@tableView = table_view(
:columns => [column(:id => :item, :title 
=> '')],
:data => @filteredData
)


@tableView.doubleAction = 'doubleClickInRow:'

def @tableView.doubleClickInRow (sender)
NSLog "in double click"
end

When I run and double click on a row in the table I get:

*** -[RBAnonymous132 doubleClickInRow:]: unrecognized selector sent  
to instance 0x8005d1c40



Does anyone know how to get this to work?

Thanks,

Dave.
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


Re: [MacRuby-devel] HotCocoa table_view and the doubleAction

2009-04-01 Thread Dave Baldwin

Quoting John Shea :

> Hi Dave,
>
> I am actually wrestling with a similar problem.
>
>   I believe I have solved your problem, maybe you can solve  
mine ;-) ??

>
> in the start method I placed:
>@my_table_view.setTarget(self)
>@my_table_view.setDoubleAction(:double)
>
>
> and then later on a method:
>
>def double
>  NSLog ("double")
>end
>

This worked so thanks, but did have the side effect of making the  
single click action fail.  I think this was because I was setting it  
up using


@tableView.on_action do
NSLog "got table action via on_action..."
end

which seems to add the action method to a proxy object and behind the  
scenes sets target to the proxy object.


Easily fixed by
@tableView.target = self
@tableView.doubleAction = 'double:'
@tableView.action = 'single:'

and
def double (sender)
end

def single (sender)
end

In actual fact I was also using the tableViewSelectionDidChange   
delegate so was finding out about single clicks twice.


>
> My issue is also delegating table updates to certain methods.
>
> I noticed that tableview.setDelegate(self) did not do anything - and
> then I assumed that the TableDataSource is actually handling the
> delegate  - confirmed when I changed the numberOfRowsInTableView
> method to return the value 1.

I haven't had any problems using delegate methods. For example I do:

@tableView.delegate = self

and define a delegate method:

def tableView (table, shouldEditTableColumn: c, row: r)
false
end

as you get told which tableView is 'calling' you you can use this to  
do table specific actions if one object is acting as a delegate for  
two tableViews.  More commonly the tableView is looked after by its  
own instance object so the setting of the delegate of the tableView  
will be unique for the different tableViews.


If you don't get the delegate's method signature correct they it will  
look like the delegate isn't working.


>
> But then I assume that I am not supposed to add my own tableView(tv,
> setObjectValue:anObject, forTableColumn:col, row:row) method to the
> HotCocoa TableDataSource file?

I don't believe so.

>
> What happens if I have two tables in the one application with
> different delegated behaviour?

Use two objects - one per tableView - to customise the delegated  
behaviour you want, or use the table argument to the delegate method  
so choose the behaviour.


>
> Am I supposed to get funky and add the different versions of the
> tableView methods to the data instance itself?
> Is there a way to override the delegate dispatch to actually go a
> local class?

I think this is what the setDelegate method does.

Hope this helps,

Dave.

>
> or do I setActions like in the double clicked example above?
>
> Cheers and thanks,
> J
>
> ___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


Re: [MacRuby-devel] HotCocoa table_view and the doubleAction

2009-04-01 Thread John Shea

Hi Dave,

thanks for your answer.

On Apr 1, 2009, at 14:39 , Dave Baldwin wrote:


I haven't had any problems using delegate methods. For example I do:

@tableView.delegate = self

and define a delegate method:

def tableView (table, shouldEditTableColumn: c, row: r)
false
end


Thats the first thing I tried - but for the tableView(table,  
setObjectValue .. method which was not delegated to.


Unfortunately as it was the first one i tried (because i wanted to  
edit table fields) -  that sent me on a wild goose chase trying to  
figure out why the delegate was not working as it was in all of my non- 
hotcocoa code.


So thanks for pointing out that some of them are actually delegated to.

For me:


  #works
  def controlTextDidChange(notification)
  NSLog("controlTextDidChange #{notification.object}")
  NSLog(@mv_table_view.selectedRow.to_s)
  end

  #works
  def tableView(tv, willDisplayCell:cell, forTableColumn:col,  
row:the_row)

   NSLog("willDisplayCell")
  end

  #works
  def tableViewSelectionDidChange(notification)
NSLog("tableViewSelectionDidChange")
  end

#is not delegated to
  def tableView(tv, setObjectValue:anObject, forTableColumn:col,  
row:row)

NSLog("tableView setObject")
#edit data here
  end

#is not delegated to
  def numberOfRowsInTableView(tv)
NSLog("numberOfRowsInTableView")
0 #test 0
  end

#is not delegated to
  def tableView(tv, objectValueForTableColumn:col, row:row)
NSLog("objectValueForTableColumn")
val = "richard"
  end


I could probably do a work around with controlTextDidChange - but it  
seems a bit dodgy.
Or another option would be to edit not within the table, but in  
another form.


I suppose there is some simple explanation - but I am missing it for  
the moment.


Cheers,
J






___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


Re: [MacRuby-devel] Accessing Obj-C InstVars from Ruby

2009-04-01 Thread Benjamin Stiglitz
Is there a way to access instance variables defined in an  
Objective-C

class from a Ruby extension?


It is currently not implemented, but it's technically possible. A  
good work-around is to define accessors (properties) as John  
mentioned.


Maybe we need MacRuby::Runtime to bubble up the Obj-C runtime. Or FFI.

-Ben
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


Re: [MacRuby-devel] [MacRuby] #241: NSMutableSet#merge fails

2009-04-01 Thread MacRuby
#241: NSMutableSet#merge fails
--+-
 Reporter:  kou...@…  |   Owner:  b...@…  
 Type:  defect|  Status:  new
 Priority:  major |   Milestone:  MacRuby 0.4
Component:  MacRuby   |Keywords: 
--+-
Changes (by b...@…):

  * owner:  lsansone...@… => b...@…


Comment:

 Looks like I’m not properly coercing to a set.

-- 
Ticket URL: 
MacRuby 

___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


Re: [MacRuby-devel] # of developers

2009-04-01 Thread Benjamin Stiglitz

Here is the blurb:
http://www.macruby.org/project.html


I should say that I’m not a very frequent contributor, so you can  
subtract one from the #size of that list.


-Ben
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


Re: [MacRuby-devel] HotCocoa table_view and the doubleAction

2009-04-01 Thread Brian Chapados
You might have already figured this out, but in case it helps...

Be careful not to confuse the TableView delegate with the DataSource delegate.
Check out the TableView programming guide:
http://developer.apple.com/documentation/Cocoa/Conceptual/TableView/TableView.html

You can use two different sets of delegate messages to customize an
NSTableView.  The datasource delegate methods get called in order to
populate the table with data. The TableView delegate methods get
called in response to user-generated events.

The DataSource informal protocol:
http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Protocols/NSTableDataSource_Protocol/Reference/Reference.html#//apple_ref/occ/cat/NSTableDataSource

delegate methods specific for a TableView:
http://developer.apple.com/documentation/Cocoa/Conceptual/TableView/Tasks/UsingTableDelegate.html#//apple_ref/doc/uid/2116-CJBDHFIC

Your tableview delegate can also respond to delegate messages for
NSControl and NSView (its superclasses).

In your list below,
> #is not delegated to
>   def tableView(tv, setObjectValue:anObject, forTableColumn:col, row:row)
> NSLog("tableView setObject")
> #edit data here
>   end
> #is not delegated to
>   def numberOfRowsInTableView(tv)
> NSLog("numberOfRowsInTableView")
> 0 #test 0
>   end
> #is not delegated to
>   def tableView(tv, objectValueForTableColumn:col, row:row)
> NSLog("objectValueForTableColumn")
> val = "richard"
>   end

These methods are sent to the 'dataSource' delegate, not the
'delegate' (view delegate).  In order for your dataSource delegate
methods to be called, you need to either:

1. Define the methods in a separate class, and assign an instance of
that class as:
@tableView.dataSource = myDataSource

2. Define the methods in your TableView Controller class, set the
dataSource delegate to self:
@tableView.dataSource = self

You _must_ set the tableView delegate in order to receive the
messages, even if you have everything in one class and you just want
to set them to 'self'.

For simple cases, you can implement both the 'dataSource' and view
'delegate' classes in your TableView controller and set both delegates
to self.  For an example of this, see the FlickrDemo example app in
macruby-examples dir.

Also, since it was mentioned, you should be able to leave the 'target'
property unset (or set it to nil).  In cocoa, nil targeted actions do
_not_ go into the void.  Instead, they sent are passed along the
responder chain so that the next appropriate control can handle the
message. This is useful for when you want to the same action to be
performed as a result of different inputs (i.e. menu, button or click
in row, ect..).  You can just define the action methods in a class
that is part of the responder chain and send a nil targeted actions
from your controls.

There is must-listen Mac-Developer Network podcast interview with
Aaron Hillegass on the Responder Chain:
http://www.mac-developer-network.com/shows/podcasts/lnc/lnc009/

Brian

2009/4/1 John Shea :
> Hi Dave,
> thanks for your answer.
>
> On Apr 1, 2009, at 14:39 , Dave Baldwin wrote:
>
> I haven't had any problems using delegate methods. For example I do:
> @tableView.delegate = self
> and define a delegate method:
> def tableView (table, shouldEditTableColumn: c, row: r)
> false
> end
>
> Thats the first thing I tried - but for the tableView(table, setObjectValue
> .. method which was not delegated to.
> Unfortunately as it was the first one i tried (because i wanted to edit
> table fields) -  that sent me on a wild goose chase trying to figure out why
> the delegate was not working as it was in all of my non-hotcocoa code.
> So thanks for pointing out that some of them are actually delegated to.
> For me:
>
>   #works
>   def controlTextDidChange(notification)
>       NSLog("controlTextDidChange #{notification.object}")
>       NSLog(@mv_table_view.selectedRow.to_s)
>   end
>
>   #works
>   def tableView(tv, willDisplayCell:cell, forTableColumn:col, row:the_row)
>    NSLog("willDisplayCell")
>   end
>   #works
>   def tableViewSelectionDidChange(notification)
>     NSLog("tableViewSelectionDidChange")
>   end
> #is not delegated to
>   def tableView(tv, setObjectValue:anObject, forTableColumn:col, row:row)
>     NSLog("tableView setObject")
>     #edit data here
>   end
> #is not delegated to
>   def numberOfRowsInTableView(tv)
>     NSLog("numberOfRowsInTableView")
>     0 #test 0
>   end
> #is not delegated to
>   def tableView(tv, objectValueForTableColumn:col, row:row)
>     NSLog("objectValueForTableColumn")
>     val = "richard"
>   end
>
> I could probably do a work around with controlTextDidChange - but it seems a
> bit dodgy.
> Or another option would be to edit not within the table, but in another
> form.
> I suppose there is some simple explanation - but I am missing it for the
> moment.
> Cheers,
> J
>
>
>
>
>
> ___
> MacRuby-devel mailing list
> MacRuby-d

[MacRuby-devel] Trac ticket 232

2009-04-01 Thread Jason Morrison
Hi MacRuby,

I built MacRuby 0.4 from SVN on OSX 10.5.6 (x86) successfully, but
could not run the example applications.  I found
http://www.macruby.org/trac/ticket/232 and thought that perhaps I was
having the same issue, though I couldn't find any additional
discussion on that issue:

$ open ./ABPresence.app
LSOpenFromURLSpec() failed with error -10810 for the file
/Users/jasonmorrison/dev/MacRuby-trunk/sample-macruby/bin/ABPresence.app.

I eventually found out that the bundled executables were not chmodded
+x, and doing so fixed it:

$ pwd
/Users/jasonmorrison/dev/MacRuby-trunk/sample-macruby/bin
$ ls
ABPresence.app/  CircleView.app/  EmbeddedMacRuby.app/
OutlineView.app/  PathDemo.app/    ViewModelDemo.app/
AnimatingViews.app/  DotView.app/ FlickrDemo.app/
PagePacker.app/   RoundTransparentWindow.app/
$ chmod u+x FlickrDemo.app/Contents/MacOS/FlickrDemo
$ open ./FlickrDemo.app # and off we go...

So, I signed up for Trac, went back to the ticket, with the intent of
commenting on it.  Alas!   I saw:

Trac detected an internal error: SubversionException: ('unable to open
database file', 200030)

So, this post to the mailing list is the best I can do, I think.  I
hope this helps someone!

Cheers,
-Jason

--
Jason Morrison
[email protected]
http://jayunit.net
(585) 216-5657
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


Re: [MacRuby-devel] Trac ticket 232

2009-04-01 Thread Jason Morrison
Attaching patch to chmod 0755 the executables.

On Wed, Apr 1, 2009 at 9:03 PM, Jason Morrison
 wrote:
> Hi MacRuby,
>
> I built MacRuby 0.4 from SVN on OSX 10.5.6 (x86) successfully, but
> could not run the example applications.  I found
> http://www.macruby.org/trac/ticket/232 and thought that perhaps I was
> having the same issue, though I couldn't find any additional
> discussion on that issue:
>
> $ open ./ABPresence.app
> LSOpenFromURLSpec() failed with error -10810 for the file
> /Users/jasonmorrison/dev/MacRuby-trunk/sample-macruby/bin/ABPresence.app.
>
> I eventually found out that the bundled executables were not chmodded
> +x, and doing so fixed it:
>
> $ pwd
> /Users/jasonmorrison/dev/MacRuby-trunk/sample-macruby/bin
> $ ls
> ABPresence.app/  CircleView.app/  EmbeddedMacRuby.app/
> OutlineView.app/  PathDemo.app/    ViewModelDemo.app/
> AnimatingViews.app/  DotView.app/ FlickrDemo.app/
> PagePacker.app/   RoundTransparentWindow.app/
> $ chmod u+x FlickrDemo.app/Contents/MacOS/FlickrDemo
> $ open ./FlickrDemo.app # and off we go...
>
> So, I signed up for Trac, went back to the ticket, with the intent of
> commenting on it.  Alas!   I saw:
>
> Trac detected an internal error: SubversionException: ('unable to open
> database file', 200030)
>
> So, this post to the mailing list is the best I can do, I think.  I
> hope this helps someone!
>
> Cheers,
> -Jason
>
> --
> Jason Morrison
> [email protected]
> http://jayunit.net
> (585) 216-5657
>



-- 
Jason Morrison
[email protected]
http://jayunit.net
(585) 216-5657


sample-macruby_buildall.rb.patch
Description: Binary data
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


Re: [MacRuby-devel] HotCocoa table_view and the doubleAction

2009-04-01 Thread John Shea

Thanks Brian!

that cleared up all the remaining puzzles !

I must admit i just assumed that the data source and delegate were  
married together in some way in hotcocoa - now that you have given me  
a much better background it all now makes sense.


And thanks for the link.

Cheers,
John


On Apr 1, 2009, at 8:07 PM, Brian Chapados wrote:


You might have already figured this out, but in case it helps...

Be careful not to confuse the TableView delegate with the DataSource  
delegate.

Check out the TableView programming guide:
http://developer.apple.com/documentation/Cocoa/Conceptual/TableView/TableView.html

You can use two different sets of delegate messages to customize an
NSTableView.  The datasource delegate methods get called in order to
populate the table with data. The TableView delegate methods get
called in response to user-generated events.

The DataSource informal protocol:
http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Protocols/NSTableDataSource_Protocol/Reference/Reference.html#/ 
/apple_ref/occ/cat/NSTableDataSource


delegate methods specific for a TableView:
http://developer.apple.com/documentation/Cocoa/Conceptual/TableView/Tasks/UsingTableDelegate.html#/ 
/apple_ref/doc/uid/2116-CJBDHFIC


Your tableview delegate can also respond to delegate messages for
NSControl and NSView (its superclasses).

In your list below,

#is not delegated to
 def tableView(tv, setObjectValue:anObject, forTableColumn:col,  
row:row)

   NSLog("tableView setObject")
   #edit data here
 end
#is not delegated to
 def numberOfRowsInTableView(tv)
   NSLog("numberOfRowsInTableView")
   0 #test 0
 end
#is not delegated to
 def tableView(tv, objectValueForTableColumn:col, row:row)
   NSLog("objectValueForTableColumn")
   val = "richard"
 end


These methods are sent to the 'dataSource' delegate, not the
'delegate' (view delegate).  In order for your dataSource delegate
methods to be called, you need to either:

1. Define the methods in a separate class, and assign an instance of
that class as:
@tableView.dataSource = myDataSource

2. Define the methods in your TableView Controller class, set the
dataSource delegate to self:
@tableView.dataSource = self

You _must_ set the tableView delegate in order to receive the
messages, even if you have everything in one class and you just want
to set them to 'self'.

For simple cases, you can implement both the 'dataSource' and view
'delegate' classes in your TableView controller and set both delegates
to self.  For an example of this, see the FlickrDemo example app in
macruby-examples dir.

Also, since it was mentioned, you should be able to leave the 'target'
property unset (or set it to nil).  In cocoa, nil targeted actions do
_not_ go into the void.  Instead, they sent are passed along the
responder chain so that the next appropriate control can handle the
message. This is useful for when you want to the same action to be
performed as a result of different inputs (i.e. menu, button or click
in row, ect..).  You can just define the action methods in a class
that is part of the responder chain and send a nil targeted actions
from your controls.

There is must-listen Mac-Developer Network podcast interview with
Aaron Hillegass on the Responder Chain:
http://www.mac-developer-network.com/shows/podcasts/lnc/lnc009/

Brian

2009/4/1 John Shea :

Hi Dave,
thanks for your answer.

On Apr 1, 2009, at 14:39 , Dave Baldwin wrote:

I haven't had any problems using delegate methods. For example I do:
@tableView.delegate = self
and define a delegate method:
def tableView (table, shouldEditTableColumn: c, row: r)
false
end

Thats the first thing I tried - but for the tableView(table,  
setObjectValue

.. method which was not delegated to.
Unfortunately as it was the first one i tried (because i wanted to  
edit
table fields) -  that sent me on a wild goose chase trying to  
figure out why
the delegate was not working as it was in all of my non-hotcocoa  
code.
So thanks for pointing out that some of them are actually delegated  
to.

For me:

  #works
  def controlTextDidChange(notification)
  NSLog("controlTextDidChange #{notification.object}")
  NSLog(@mv_table_view.selectedRow.to_s)
  end

  #works
  def tableView(tv, willDisplayCell:cell, forTableColumn:col,  
row:the_row)

   NSLog("willDisplayCell")
  end
  #works
  def tableViewSelectionDidChange(notification)
NSLog("tableViewSelectionDidChange")
  end
#is not delegated to
  def tableView(tv, setObjectValue:anObject, forTableColumn:col,  
row:row)

NSLog("tableView setObject")
#edit data here
  end
#is not delegated to
  def numberOfRowsInTableView(tv)
NSLog("numberOfRowsInTableView")
0 #test 0
  end
#is not delegated to
  def tableView(tv, objectValueForTableColumn:col, row:row)
NSLog("objectValueForTableColumn")
val = "richard"
  end

I could probably do a work around with controlTextDidChange - but  
it seems a

bit dodgy.
Or another option would be to edit not 

Re: [MacRuby-devel] Trac ticket 232

2009-04-01 Thread William Siegrist


On Apr 1, 2009, at 6:03 PM, Jason Morrison wrote:




snip...


So, I signed up for Trac, went back to the ticket, with the intent of
commenting on it.  Alas!   I saw:

Trac detected an internal error: SubversionException: ('unable to open
database file', 200030)




That error would be my fault. We upgraded to subversion 1.6 and  
screwed up some permissions in the process... Everything should be  
working again. Sorry for the downtime!


-Bill
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel


Re: [MacRuby-devel] Trac ticket 232

2009-04-01 Thread Matt Aimonetti
Bill,

 Thanks for taking care of the repo and the ticketing system, that's much
appreciated.

- Matt

On Wed, Apr 1, 2009 at 11:21 PM, William Siegrist wrote:

>
> On Apr 1, 2009, at 6:03 PM, Jason Morrison wrote:
>
>
>>  snip...
>
>  So, I signed up for Trac, went back to the ticket, with the intent of
>> commenting on it.  Alas!   I saw:
>>
>> Trac detected an internal error: SubversionException: ('unable to open
>> database file', 200030)
>>
>>
>
> That error would be my fault. We upgraded to subversion 1.6 and screwed up
> some permissions in the process... Everything should be working again. Sorry
> for the downtime!
>
> -Bill
>
> ___
> MacRuby-devel mailing list
> [email protected]
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel