Draw an NSOutlineView background that tracks the last row











up vote
0
down vote

favorite












I am building an outliner in which users make notes. The NSOutlineView is in a NSScrollView which is the full height of the window. I would like to have a plain background behind the NSOutlineView that exactly tracks some margin below the bottom row in the outliner.



The scrollView has elasticity at the ends of its scrolling behaviour. The NSOutlineView animates when in expands/collapses. Users can add new rows, and typing in a row can increase the row height. This gives many variations of movement to the rows.



At the moment I am able to catch some changes in the position of the last row. I override and catch layout() on the NSOutlineView and catch boundsChangedNotifications on the scrollView contentView.



The problem is that layout() is only called on the outlineView at the beginning and end of animation sequences. If I animate changes to the background it almost tracks the same movement, but the animation breaks tracking of any scrollview motion.



I really need to catch updates each frame (as in render) and set the background height. How can I do this? Is there a far more simple way that I am missing?



I don't want to add fake rows to the outline view to to this, as it would make other functionality such as drag and drop very complex.



I am not using Interface Builder.










share|improve this question






















  • At the moment I am using a timer to update a layer in my background view every 0.01 seconds. It is OK, but I can see some lag in its movement relative to the outline rows in some situations. I would be great if I could make sure this was called after all animations were updated, but before drawing takes place. Is this possible?
    – Giles
    Nov 23 at 14:33










  • Maybe adding a CoreAnimation Action for the position, frame, or bounds of the layer for the last cell in the outline view and then doing your update in the action handler? developer.apple.com/library/archive/documentation/Cocoa/… and developer.apple.com/library/archive/documentation/Cocoa/… and related. Or maybe the layer for contentView?
    – Dad
    Nov 28 at 0:52












  • Thanks @Dad. That looks to be just what I need. The content view doesn't seem to ever change, so I will try it out on the last row in time and post here.
    – Giles
    Nov 28 at 17:47















up vote
0
down vote

favorite












I am building an outliner in which users make notes. The NSOutlineView is in a NSScrollView which is the full height of the window. I would like to have a plain background behind the NSOutlineView that exactly tracks some margin below the bottom row in the outliner.



The scrollView has elasticity at the ends of its scrolling behaviour. The NSOutlineView animates when in expands/collapses. Users can add new rows, and typing in a row can increase the row height. This gives many variations of movement to the rows.



At the moment I am able to catch some changes in the position of the last row. I override and catch layout() on the NSOutlineView and catch boundsChangedNotifications on the scrollView contentView.



The problem is that layout() is only called on the outlineView at the beginning and end of animation sequences. If I animate changes to the background it almost tracks the same movement, but the animation breaks tracking of any scrollview motion.



I really need to catch updates each frame (as in render) and set the background height. How can I do this? Is there a far more simple way that I am missing?



I don't want to add fake rows to the outline view to to this, as it would make other functionality such as drag and drop very complex.



I am not using Interface Builder.










share|improve this question






















  • At the moment I am using a timer to update a layer in my background view every 0.01 seconds. It is OK, but I can see some lag in its movement relative to the outline rows in some situations. I would be great if I could make sure this was called after all animations were updated, but before drawing takes place. Is this possible?
    – Giles
    Nov 23 at 14:33










  • Maybe adding a CoreAnimation Action for the position, frame, or bounds of the layer for the last cell in the outline view and then doing your update in the action handler? developer.apple.com/library/archive/documentation/Cocoa/… and developer.apple.com/library/archive/documentation/Cocoa/… and related. Or maybe the layer for contentView?
    – Dad
    Nov 28 at 0:52












  • Thanks @Dad. That looks to be just what I need. The content view doesn't seem to ever change, so I will try it out on the last row in time and post here.
    – Giles
    Nov 28 at 17:47













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I am building an outliner in which users make notes. The NSOutlineView is in a NSScrollView which is the full height of the window. I would like to have a plain background behind the NSOutlineView that exactly tracks some margin below the bottom row in the outliner.



The scrollView has elasticity at the ends of its scrolling behaviour. The NSOutlineView animates when in expands/collapses. Users can add new rows, and typing in a row can increase the row height. This gives many variations of movement to the rows.



At the moment I am able to catch some changes in the position of the last row. I override and catch layout() on the NSOutlineView and catch boundsChangedNotifications on the scrollView contentView.



The problem is that layout() is only called on the outlineView at the beginning and end of animation sequences. If I animate changes to the background it almost tracks the same movement, but the animation breaks tracking of any scrollview motion.



I really need to catch updates each frame (as in render) and set the background height. How can I do this? Is there a far more simple way that I am missing?



I don't want to add fake rows to the outline view to to this, as it would make other functionality such as drag and drop very complex.



I am not using Interface Builder.










share|improve this question













I am building an outliner in which users make notes. The NSOutlineView is in a NSScrollView which is the full height of the window. I would like to have a plain background behind the NSOutlineView that exactly tracks some margin below the bottom row in the outliner.



The scrollView has elasticity at the ends of its scrolling behaviour. The NSOutlineView animates when in expands/collapses. Users can add new rows, and typing in a row can increase the row height. This gives many variations of movement to the rows.



At the moment I am able to catch some changes in the position of the last row. I override and catch layout() on the NSOutlineView and catch boundsChangedNotifications on the scrollView contentView.



The problem is that layout() is only called on the outlineView at the beginning and end of animation sequences. If I animate changes to the background it almost tracks the same movement, but the animation breaks tracking of any scrollview motion.



I really need to catch updates each frame (as in render) and set the background height. How can I do this? Is there a far more simple way that I am missing?



I don't want to add fake rows to the outline view to to this, as it would make other functionality such as drag and drop very complex.



I am not using Interface Builder.







cocoa nstableview nsoutlineview






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 22 at 17:23









Giles

327211




327211












  • At the moment I am using a timer to update a layer in my background view every 0.01 seconds. It is OK, but I can see some lag in its movement relative to the outline rows in some situations. I would be great if I could make sure this was called after all animations were updated, but before drawing takes place. Is this possible?
    – Giles
    Nov 23 at 14:33










  • Maybe adding a CoreAnimation Action for the position, frame, or bounds of the layer for the last cell in the outline view and then doing your update in the action handler? developer.apple.com/library/archive/documentation/Cocoa/… and developer.apple.com/library/archive/documentation/Cocoa/… and related. Or maybe the layer for contentView?
    – Dad
    Nov 28 at 0:52












  • Thanks @Dad. That looks to be just what I need. The content view doesn't seem to ever change, so I will try it out on the last row in time and post here.
    – Giles
    Nov 28 at 17:47


















  • At the moment I am using a timer to update a layer in my background view every 0.01 seconds. It is OK, but I can see some lag in its movement relative to the outline rows in some situations. I would be great if I could make sure this was called after all animations were updated, but before drawing takes place. Is this possible?
    – Giles
    Nov 23 at 14:33










  • Maybe adding a CoreAnimation Action for the position, frame, or bounds of the layer for the last cell in the outline view and then doing your update in the action handler? developer.apple.com/library/archive/documentation/Cocoa/… and developer.apple.com/library/archive/documentation/Cocoa/… and related. Or maybe the layer for contentView?
    – Dad
    Nov 28 at 0:52












  • Thanks @Dad. That looks to be just what I need. The content view doesn't seem to ever change, so I will try it out on the last row in time and post here.
    – Giles
    Nov 28 at 17:47
















At the moment I am using a timer to update a layer in my background view every 0.01 seconds. It is OK, but I can see some lag in its movement relative to the outline rows in some situations. I would be great if I could make sure this was called after all animations were updated, but before drawing takes place. Is this possible?
– Giles
Nov 23 at 14:33




At the moment I am using a timer to update a layer in my background view every 0.01 seconds. It is OK, but I can see some lag in its movement relative to the outline rows in some situations. I would be great if I could make sure this was called after all animations were updated, but before drawing takes place. Is this possible?
– Giles
Nov 23 at 14:33












Maybe adding a CoreAnimation Action for the position, frame, or bounds of the layer for the last cell in the outline view and then doing your update in the action handler? developer.apple.com/library/archive/documentation/Cocoa/… and developer.apple.com/library/archive/documentation/Cocoa/… and related. Or maybe the layer for contentView?
– Dad
Nov 28 at 0:52






Maybe adding a CoreAnimation Action for the position, frame, or bounds of the layer for the last cell in the outline view and then doing your update in the action handler? developer.apple.com/library/archive/documentation/Cocoa/… and developer.apple.com/library/archive/documentation/Cocoa/… and related. Or maybe the layer for contentView?
– Dad
Nov 28 at 0:52














Thanks @Dad. That looks to be just what I need. The content view doesn't seem to ever change, so I will try it out on the last row in time and post here.
– Giles
Nov 28 at 17:47




Thanks @Dad. That looks to be just what I need. The content view doesn't seem to ever change, so I will try it out on the last row in time and post here.
– Giles
Nov 28 at 17:47

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53435795%2fdraw-an-nsoutlineview-background-that-tracks-the-last-row%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53435795%2fdraw-an-nsoutlineview-background-that-tracks-the-last-row%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

What visual should I use to simply compare current year value vs last year in Power BI desktop

How to ignore python UserWarning in pytest?

Alexandru Averescu