Re: How to change highlight colour on NSTableView row
Hi, Thanks for the post. I've tried your suggestion but it doesn't change the default rendering I'm afraid. Here's what I did: - created an NSTextFieldCell subclass - Added the method you suggested - changed the table cells in the NSTableView defined in IB to use my new subclass Was that the correct approach? Regards Darren. On 22/10/2013 21:06, Corbin Dunn wrote: On Oct 22, 2013, at 5:36 AM, Darren Wheatley dar...@tenjinconsulting.co.uk wrote: Hi, Thanks for the reply. I tried the code sample you suggested but can't get it to work. When running the default highlighting is being layered on top of this custom highlighting (I can see part of the custom highlighting where the rects are not quite overlapping). Do you know how I prevent the standard formatting from being displayed? Your cell is drawing that part; Override: - (NSColor *)highlightColorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView; and return nil as an easy work around. Also, (might be a symptom of the above) the custom highlighting is not always removed when I click on a new row. If I scroll those rows off the screen and back on the highlighting is fixed, so there is some sort of display refresh problem. If you are drawing outside of the “normal” highlight area, then you are responsible for invalidating it when selection changes. corbin I have tried standard and source list highlighting (set in the xib), and both display the same behaviour. Do you know what might be going on here, or anything I should check in my code? Any suggestions you could make would be very much appreciated. FYI, I am developing on 10.8.5 and targeting 10.7. Regards Darren. On 21 Oct 2013, at 17:23, jonat...@mugginsoft.com wrote: On 21 Oct 2013, at 16:19, Darren Wheatley dar...@tenjinconsulting.co.uk wrote: Hi, I have a custom subclass of NSTableView in my app. Can anyone suggest a method that will allow me to set a custom highlight colour on on a row when the user clicks on it? I've Googled for a solution, but haven't been able to find anything that works. For cell based tables try: - (void)highlightSelectionInClipRect:(NSRect)clipRect There is a sample implementation at http://stackoverflow.com/questions/7038709/change-highlighting-color-in-nstableview-in-cocoa. You may need to set selectionHighlightStyle to NSTableViewSelectionHighlightStyleSourceList Note: This method should not be subclassed or overridden for a view-base table view. Instead, row drawing customization should be done by subclassing NSTableRowView. Jonathan ___ 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/darren%40tenjinconsulting.co.uk This email sent to dar...@tenjinconsulting.co.uk ___ 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/corbind%40apple.com This email sent to corb...@apple.com ___ 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: How to change highlight colour on NSTableView row
I blogged about themeing NSTableView a while ago: http://orangejuiceliberationfront.com/themeing-nstableview/ That lists all the steps for changing highlight and other colors. Did you not see that via Google? Does that not work for you for some reason? I have a shipping application that uses this approach, and haven't heard any reports from users that the selection color was wrong. -- Uli Kusterer The Witnesses of TeachText are everywhere... On 21 Oct 2013, at 17:19, Darren Wheatley dar...@tenjinconsulting.co.uk wrote: Hi, I have a custom subclass of NSTableView in my app. I would like to change the highlight colour displayed when the user clicks on a row, and have the colour maintained when the NSTableView subclass loses focus. I have changed the subclass to ensure that the table is never first responder, and so the user only ever sees the lost focus highlight colour (gray by default). This maintains the same highlight colour when the table has focus, and when it doesn't. I would now like to change the default gray colour to a custom colour. My tableview is currently cell-based. I am targeting 10.7+ so I could switch to view-based if that would give me more options? Can anyone suggest a method that will allow me to set a custom highlight colour on on a row when the user clicks on it? I've Googled for a solution, but haven't been able to find anything that works. Thanks Darren. ___ 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/witness.of.teachtext%40gmx.net This email sent to witness.of.teacht...@gmx.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: How to change highlight colour on NSTableView row
Hi, Thanks for the reply. I tried the code sample you suggested but can't get it to work. When running the default highlighting is being layered on top of this custom highlighting (I can see part of the custom highlighting where the rects are not quite overlapping). Do you know how I prevent the standard formatting from being displayed? Also, (might be a symptom of the above) the custom highlighting is not always removed when I click on a new row. If I scroll those rows off the screen and back on the highlighting is fixed, so there is some sort of display refresh problem. I have tried standard and source list highlighting (set in the xib), and both display the same behaviour. Do you know what might be going on here, or anything I should check in my code? Any suggestions you could make would be very much appreciated. FYI, I am developing on 10.8.5 and targeting 10.7. Regards Darren. On 21 Oct 2013, at 17:23, jonat...@mugginsoft.com wrote: On 21 Oct 2013, at 16:19, Darren Wheatley dar...@tenjinconsulting.co.uk wrote: Hi, I have a custom subclass of NSTableView in my app. Can anyone suggest a method that will allow me to set a custom highlight colour on on a row when the user clicks on it? I've Googled for a solution, but haven't been able to find anything that works. For cell based tables try: - (void)highlightSelectionInClipRect:(NSRect)clipRect There is a sample implementation at http://stackoverflow.com/questions/7038709/change-highlighting-color-in-nstableview-in-cocoa. You may need to set selectionHighlightStyle to NSTableViewSelectionHighlightStyleSourceList Note: This method should not be subclassed or overridden for a view-base table view. Instead, row drawing customization should be done by subclassing NSTableRowView. Jonathan ___ 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/darren%40tenjinconsulting.co.uk This email sent to dar...@tenjinconsulting.co.uk ___ 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: How to change highlight colour on NSTableView row
Hi, Thanks for the reply. I tried the code sample you suggested but can't get it to work. When running the default highlighting is being layered on top of this custom highlighting (I can see part of the custom highlighting where the rects are not quite overlapping). Do you know how I prevent the standard formatting from being displayed? Also, (might be a symptom of the above) the custom highlighting is not always removed when I click on a new row. If I scroll those rows off the screen and back on the highlighting is fixed, so there is some sort of display refresh problem. I have tried standard and source list highlighting (set in the xib), and both display the same behaviour. Do you know what might be going on here, or anything I should check in my code? Any suggestions you could make would be very much appreciated. FYI, I am developing on 10.8.5 and targeting 10.7. Regards Darren. On 21 Oct 2013, at 17:23, jonat...@mugginsoft.com wrote: On 21 Oct 2013, at 16:19, Darren Wheatley dar...@tenjinconsulting.co.uk wrote: Hi, I have a custom subclass of NSTableView in my app. Can anyone suggest a method that will allow me to set a custom highlight colour on on a row when the user clicks on it? I've Googled for a solution, but haven't been able to find anything that works. For cell based tables try: - (void)highlightSelectionInClipRect:(NSRect)clipRect There is a sample implementation at http://stackoverflow.com/questions/7038709/change-highlighting-color-in-nstableview-in-cocoa. You may need to set selectionHighlightStyle to NSTableViewSelectionHighlightStyleSourceList Note: This method should not be subclassed or overridden for a view-base table view. Instead, row drawing customization should be done by subclassing NSTableRowView. Jonathan ___ 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/darren%40tenjinconsulting.co.uk This email sent to dar...@tenjinconsulting.co.uk ___ 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: How to change highlight colour on NSTableView row
On Oct 22, 2013, at 5:36 AM, Darren Wheatley dar...@tenjinconsulting.co.uk wrote: Hi, Thanks for the reply. I tried the code sample you suggested but can't get it to work. When running the default highlighting is being layered on top of this custom highlighting (I can see part of the custom highlighting where the rects are not quite overlapping). Do you know how I prevent the standard formatting from being displayed? Your cell is drawing that part; Override: - (NSColor *)highlightColorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView; and return nil as an easy work around. Also, (might be a symptom of the above) the custom highlighting is not always removed when I click on a new row. If I scroll those rows off the screen and back on the highlighting is fixed, so there is some sort of display refresh problem. If you are drawing outside of the “normal” highlight area, then you are responsible for invalidating it when selection changes. corbin I have tried standard and source list highlighting (set in the xib), and both display the same behaviour. Do you know what might be going on here, or anything I should check in my code? Any suggestions you could make would be very much appreciated. FYI, I am developing on 10.8.5 and targeting 10.7. Regards Darren. On 21 Oct 2013, at 17:23, jonat...@mugginsoft.com wrote: On 21 Oct 2013, at 16:19, Darren Wheatley dar...@tenjinconsulting.co.uk wrote: Hi, I have a custom subclass of NSTableView in my app. Can anyone suggest a method that will allow me to set a custom highlight colour on on a row when the user clicks on it? I've Googled for a solution, but haven't been able to find anything that works. For cell based tables try: - (void)highlightSelectionInClipRect:(NSRect)clipRect There is a sample implementation at http://stackoverflow.com/questions/7038709/change-highlighting-color-in-nstableview-in-cocoa. You may need to set selectionHighlightStyle to NSTableViewSelectionHighlightStyleSourceList Note: This method should not be subclassed or overridden for a view-base table view. Instead, row drawing customization should be done by subclassing NSTableRowView. Jonathan ___ 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/darren%40tenjinconsulting.co.uk This email sent to dar...@tenjinconsulting.co.uk ___ 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/corbind%40apple.com This email sent to corb...@apple.com ___ 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
How to change highlight colour on NSTableView row
Hi, I have a custom subclass of NSTableView in my app. I would like to change the highlight colour displayed when the user clicks on a row, and have the colour maintained when the NSTableView subclass loses focus. I have changed the subclass to ensure that the table is never first responder, and so the user only ever sees the lost focus highlight colour (gray by default). This maintains the same highlight colour when the table has focus, and when it doesn't. I would now like to change the default gray colour to a custom colour. My tableview is currently cell-based. I am targeting 10.7+ so I could switch to view-based if that would give me more options? Can anyone suggest a method that will allow me to set a custom highlight colour on on a row when the user clicks on it? I've Googled for a solution, but haven't been able to find anything that works. Thanks Darren. ___ 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: How to change highlight colour on NSTableView row
On 21 Oct 2013, at 16:19, Darren Wheatley dar...@tenjinconsulting.co.uk wrote: Hi, I have a custom subclass of NSTableView in my app. Can anyone suggest a method that will allow me to set a custom highlight colour on on a row when the user clicks on it? I've Googled for a solution, but haven't been able to find anything that works. For cell based tables try: - (void)highlightSelectionInClipRect:(NSRect)clipRect There is a sample implementation at http://stackoverflow.com/questions/7038709/change-highlighting-color-in-nstableview-in-cocoa. You may need to set selectionHighlightStyle to NSTableViewSelectionHighlightStyleSourceList Note: This method should not be subclassed or overridden for a view-base table view. Instead, row drawing customization should be done by subclassing NSTableRowView. Jonathan ___ 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