Re: PopUp menus in tables

2016-10-05 Thread Quincey Morris
On Oct 5, 2016, at 14:26 , Frank D. Engel, Jr.  wrote:
> 
> What little experience I have had so far with view-based tables has been less 
> than good.  

There’s no particular reason to believe that this particular problem would be 
easier to resolve with a cell-based table.

> They create more work with no practical benefit that I can determine.

The practical benefit is to free you from having to use NSCells, which are 
obsolescent if not obsolete. There’s “more work” in the sense that if a single 
view cell contains multiple UI elements, there’s more to do per view cell. 
There’s “more work” if you’re using autolayout within a view cell. Other than 
those things, I’m not sure what extra work is created.

> I've been thinking about trying to figure out how to ditch the constraint 
> system in some of my xib files for the more traditional position/size system 
> for a similar reason.


This is unrelated to the issues you’ve raised in this thread. You can of course 
choose to bypass autolayout in any XIB file (uncheck “Use Auto Layout” in the 
File inspector) or any view sub-hierarchy (use 
translatesAutoresizingMaskIntoConstraints on the topmost level view that you 
want to disconnect from autolayout).

___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: PopUp menus in tables

2016-10-05 Thread Frank D. Engel, Jr.
What little experience I have had so far with view-based tables has been 
less than good.  They create more work with no practical benefit that I 
can determine.  I've been thinking about trying to figure out how to 
ditch the constraint system in some of my xib files for the more 
traditional position/size system for a similar reason.


I have another idea I'm going to try; if that doesn't work out, I may be 
forced to fall back on this.



Thank you!


On 10/4/2016 20:59, Gary L. Wade wrote:

If you’re using a view-based table view (as all should be nowadays), and you 
have the popup button you clicked on, get the enclosing NSTableRowView and call 
rowForView:
--
Gary L. Wade
http://www.garywade.com/ 

On Oct 4, 2016, at 4:03 PM, Steve Mills  wrote:


On Oct 4, 2016, at 17:39, Frank D. Engel, Jr.  wrote:

Ok - wasn't aware of that one.

I tried it, but sadly get the same results.

Huh. I just used it the other day for handling right-clicks in tables and it 
works correctly for that.

Steve via iPad


___

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:
https://lists.apple.com/mailman/options/cocoa-dev/fde101%40fjrhome.net

This email sent to fde...@fjrhome.net



___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: PopUp menus in tables

2016-10-04 Thread Gary L. Wade
If you’re using a view-based table view (as all should be nowadays), and you 
have the popup button you clicked on, get the enclosing NSTableRowView and call 
rowForView:
--
Gary L. Wade
http://www.garywade.com/ 
> On Oct 4, 2016, at 4:03 PM, Steve Mills  wrote:
> 
>> On Oct 4, 2016, at 17:39, Frank D. Engel, Jr.  wrote:
>> 
>> Ok - wasn't aware of that one.
>> 
>> I tried it, but sadly get the same results.
> 
> Huh. I just used it the other day for handling right-clicks in tables and it 
> works correctly for that.
> 
> Steve via iPad
> 
___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: PopUp menus in tables

2016-10-04 Thread Steve Mills
> On Oct 4, 2016, at 17:39, Frank D. Engel, Jr.  wrote:
> 
> Ok - wasn't aware of that one.
> 
> I tried it, but sadly get the same results.

Huh. I just used it the other day for handling right-clicks in tables and it 
works correctly for that.

Steve via iPad


___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: PopUp menus in tables

2016-10-04 Thread Frank D. Engel, Jr.

Ok - wasn't aware of that one.

I tried it, but sadly get the same results.


On 10/3/2016 23:17, Steve Mills wrote:

On Oct 3, 2016, at 18:29:34, Frank D. Engel, Jr.  wrote:

Does anyone know of a way to determine which row of the table the menu is being 
opened for, rather than the one that was selected before I tried to open it?

You need to use clickedRow.

--
Steve Mills
Drummer, Mac geek


___

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:
https://lists.apple.com/mailman/options/cocoa-dev/fde101%40fjrhome.net

This email sent to fde...@fjrhome.net



___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

Re: PopUp menus in tables

2016-10-03 Thread Steve Mills
On Oct 3, 2016, at 18:29:34, Frank D. Engel, Jr.  wrote:
> 
> Does anyone know of a way to determine which row of the table the menu is 
> being opened for, rather than the one that was selected before I tried to 
> open it?

You need to use clickedRow.

--
Steve Mills
Drummer, Mac geek


___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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

PopUp menus in tables

2016-10-03 Thread Frank D. Engel, Jr.

Hi,

I have an NSPopupButtonCell in a cell-based table (MacOS X).  The table 
is being fed by an NSArrayController, but the set of items in this 
particular popup menu is fixed (entered them as NSMenuItem objects 
within Xcode's Interface Builder).


However, I need to enable/disable certain items based on various 
conditions for the particular row of the table view that I am popping up 
the menu for.


I tried binding the "enabled" property of the menu items to a property 
of the "selection" of the array controller.  At first I thought this 
wasn't working quite right, or I had an off-by-one error somewhere, but 
after playing with it for a while, I realized that it was setting the 
enabled property based on the row that was selected before I tried to 
open the menu, rather than the row of the table that the menu was on.


In other words, if the item should only be disabled for the last row of 
the table, and I open the menu on that row even though the first row had 
been highlighted before the click that opened the menu, it was enabled, 
even though the last row appeared to be selected. However, the next time 
I opened the menu, regardless of which row of the table view it was on, 
unless I selected an intermediate row first, the item was disabled - 
because the last row of the table had been selected.


To try to work around this, I removed the bindings and set one of my 
classes as the delegate of the NSMenu object that was associated with 
the popup cell, added IBOutlets to that class and pointed them to the 
table and to two menu items I wanted to set based on this condition, and 
added the following code to that class (I tweaked some names to make the 
code more clear out of context):


- (void)doMenuUpdate:(NSMenu *)menu
{
NSLog(@"here");

DataElement *el = [[tableItemsArrayController arrangedObjects] 
objectAtIndex:[theTable selectedRow]];


[item1 setEnabled:[el shouldEnableItem]];
[item2 setEnabled:[el shouldEnableItem]];
}

- (void)menuNeedsUpdate:(NSMenu *)menu
{
dispatch_async(dispatch_get_main_queue(), ^{
[self doMenuUpdate:menu];
});
}


With that code in place, I did get the "here" being displayed right 
after the menu was opened (not waiting for it to close), but the 
behavior was exactly the same as with the bindings.


It appears that the tableview is only updating its "selectedRow" 
property AFTER the menu closes, instead of when it opens.


This is not very helpful in this scenario.


Does anyone know of a way to determine which row of the table the menu 
is being opened for, rather than the one that was selected before I 
tried to open it?


I'm trying to avoid going to a view-based table as I find them 
relatively frustrating to work with and don't like the way they wind up 
looking quite as much.  I'll use them if I must, but I prefer not to.



___

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

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