Re: Bindings and MenuItems

2009-04-03 Thread Ben Lachman

On Apr 3, 2009, at 6:14 AM, Alexander Spohr wrote:


Am 03.04.2009 um 06:49 schrieb Ben Lachman:

No.  That was what my original message outlined.  Say you have a  
table view selected and hit cmd-p.  NSView has a default  
implementation of print: so it will print the table view.  In my  
case and in many others what you really want to print is the detail  
view or some representation of it that actually shows the currently  
data of the selected object(s).  So no that's not really what the  
first responder is for.


Why not subclassing that table view and overriding print:?


This breaks the MVC paradigm.  You'd have to forward print: to another  
view or better, forward it up to the controller and let the controller  
figure out what to do with it, although I think this kind of breaks  
the validateMenuItem interface.  But you still have the problem that  
many different views can be first responder.  You'd basically have to  
subclass every view that accepts first responder and override print:  
in each.  It would also make code reuse much more cumbersome.  All the  
views for one printing state would have to have a separate subclass  
from the views for the other printing state (this was my original  
issue, how do you manage printing when you have two main detail views  
that you swap between?).


->Ben
--
Ben Lachman
Acacia Tree Software

http://acaciatreesoftware.com

email: blach...@mac.com
twitter: @benlachman
mobile: 740.590.0009

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Bindings and MenuItems

2009-04-03 Thread Alexander Spohr


Am 03.04.2009 um 06:49 schrieb Ben Lachman:

No.  That was what my original message outlined.  Say you have a  
table view selected and hit cmd-p.  NSView has a default  
implementation of print: so it will print the table view.  In my  
case and in many others what you really want to print is the detail  
view or some representation of it that actually shows the currently  
data of the selected object(s).  So no that's not really what the  
first responder is for.


Why not subclassing that table view and overriding print:?

atze

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Bindings and MenuItems

2009-04-02 Thread Ben Lachman
No.  That was what my original message outlined.  Say you have a table  
view selected and hit cmd-p.  NSView has a default implementation of  
print: so it will print the table view.  In my case and in many others  
what you really want to print is the detail view or some  
representation of it that actually shows the currently data of the  
selected object(s).  So no that's not really what the first responder  
is for.


->Ben
--
Ben Lachman
Acacia Tree Software

http://acaciatreesoftware.com

email: blach...@mac.com
twitter: @benlachman
mobile: 740.590.0009



On Apr 2, 2009, at 4:49 AM, Alexander Spohr wrote:



Am 02.04.2009 um 06:59 schrieb Ben Lachman:

Yeah, I ended up reverting to just setting the target of the menu  
item in code when certain notifications happened  
(NSWindowDidBecomeKey and NSOutlineViewSelectionDidChange).  This  
works, but isn't quite as simple as a bindings based solution  
should have been. Planning to file a bug on this.


Can’t you use the first responder? That’s what it’s for.

atze



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Bindings and MenuItems

2009-04-02 Thread Alexander Spohr


Am 02.04.2009 um 06:59 schrieb Ben Lachman:

Yeah, I ended up reverting to just setting the target of the menu  
item in code when certain notifications happened  
(NSWindowDidBecomeKey and NSOutlineViewSelectionDidChange).  This  
works, but isn't quite as simple as a bindings based solution should  
have been. Planning to file a bug on this.


Can’t you use the first responder? That’s what it’s for.

atze

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Bindings and MenuItems

2009-04-01 Thread Ben Lachman

On Apr 1, 2009, at 5:01 PM, Keary Suska wrote:


On Apr 1, 2009, at 12:31 PM, Ben Lachman wrote:

I mean a "Cocoa bindings" kind of binding.  e.g. the "target"  
binding of the menu item is bound in IB.  The action field of the  
binding is set to "print:".  I'm not talking about the traditional  
way of connecting a button/menu item to another object through the  
basic control drag from source to target and select the action  
method and I'm not talking about setting it in code.  I know how to  
do both of those and they work, what I'm going for is a dynamic  
target.



I think I wasn't recalling correctly--my issue had to do with an  
NSButton, and binding didn't work for me. There is no reason to  
suspect that the binding wouldn't work as advertised.


Anyway, I suppose you have verified that the correct object is being  
set when the binding is established (and/or when the bound property  
changes)?


Yeah, I ended up reverting to just setting the target of the menu item  
in code when certain notifications happened (NSWindowDidBecomeKey and  
NSOutlineViewSelectionDidChange).  This works, but isn't quite as  
simple as a bindings based solution should have been. Planning to file  
a bug on this.


Thanks for the thoughts.

->Ben
--
Ben Lachman
Acacia Tree Software

http://acaciatreesoftware.com

email: blach...@mac.com
twitter: @benlachman
mobile: 740.590.0009



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Bindings and MenuItems

2009-04-01 Thread Keary Suska


On Apr 1, 2009, at 12:31 PM, Ben Lachman wrote:

I mean a "Cocoa bindings" kind of binding.  e.g. the "target"  
binding of the menu item is bound in IB.  The action field of the  
binding is set to "print:".  I'm not talking about the traditional  
way of connecting a button/menu item to another object through the  
basic control drag from source to target and select the action  
method and I'm not talking about setting it in code.  I know how to  
do both of those and they work, what I'm going for is a dynamic  
target.



I think I wasn't recalling correctly--my issue had to do with an  
NSButton, and binding didn't work for me. There is no reason to  
suspect that the binding wouldn't work as advertised.


Anyway, I suppose you have verified that the correct object is being  
set when the binding is established (and/or when the bound property  
changes)?


Best,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Bindings and MenuItems

2009-04-01 Thread Ben Lachman
I mean a "Cocoa bindings" kind of binding.  e.g. the "target" binding  
of the menu item is bound in IB.  The action field of the binding is  
set to "print:".  I'm not talking about the traditional way of  
connecting a button/menu item to another object through the basic  
control drag from source to target and select the action method and  
I'm not talking about setting it in code.  I know how to do both of  
those and they work, what I'm going for is a dynamic target.


->Ben
--
Ben Lachman
Acacia Tree Software

http://acaciatreesoftware.com

email: blach...@mac.com
twitter: @benlachman
mobile: 740.590.0009



On Apr 1, 2009, at 7:12 AM, Andy Lee wrote:


On Apr 1, 2009, at 3:34 AM, Ben Lachman wrote:
I have a menu item that is bound to a target.  The menu is resides  
in has "Auto Enables Items" checked which means that it should call  
-validateMenuItem on a items target if it is available.  However  
validate is never called on the target.  If I remove the binding  
and set the target to one of the objects manually in IB the  
validation method is called as expected.  Has anyone else run into  
this and if so, is there a work around?


What do you mean "binding"?  "Binding" has a very specific meaning,  
and is not how you connect an object to its target.


Do you mean you're making the connection in code?  If so, it should  
look something like:


   [myMenuItem setTarget:myTarget];
   [myMenuItem setAction:@selector(doMyAction:)];

Note the name of the action method is "doMyAction:", not  
"doMyAction", though I don't know if this affects whether  
validateMenuItem: is called.


Assuming your code does look like this, are you sure these lines of  
code are being executed?  If so, *when* are they being executed?  If  
you doing this in init, it's possible myMenuItem and myTarget have  
not been set yet -- you need to make the connection in awakeFromNib.


--Andy



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Bindings and MenuItems

2009-04-01 Thread Keary Suska

On Apr 1, 2009, at 3:34 AM, Ben Lachman wrote:

I have a menu item that is bound to a target.  The menu is resides  
in has "Auto Enables Items" checked which means that it should call - 
validateMenuItem on a items target if it is available.  However  
validate is never called on the target.  If I remove the binding and  
set the target to one of the objects manually in IB the validation  
method is called as expected.  Has anyone else run into this and if  
so, is there a work around?



IIRC, I had a situation where I discovered that both target & action  
have to be bound (i.e. key-value binding) or target-action fails  
entirely.


HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Bindings and MenuItems

2009-04-01 Thread Andy Lee

On Apr 1, 2009, at 3:34 AM, Ben Lachman wrote:
I have a menu item that is bound to a target.  The menu is resides  
in has "Auto Enables Items" checked which means that it should call - 
validateMenuItem on a items target if it is available.  However  
validate is never called on the target.  If I remove the binding and  
set the target to one of the objects manually in IB the validation  
method is called as expected.  Has anyone else run into this and if  
so, is there a work around?


What do you mean "binding"?  "Binding" has a very specific meaning,  
and is not how you connect an object to its target.


Do you mean you're making the connection in code?  If so, it should  
look something like:


[myMenuItem setTarget:myTarget];
[myMenuItem setAction:@selector(doMyAction:)];

Note the name of the action method is "doMyAction:", not "doMyAction",  
though I don't know if this affects whether validateMenuItem: is called.


Assuming your code does look like this, are you sure these lines of  
code are being executed?  If so, *when* are they being executed?  If  
you doing this in init, it's possible myMenuItem and myTarget have not  
been set yet -- you need to make the connection in awakeFromNib.


--Andy

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com