OneMore
OneMore copied to clipboard
Add functionality to synchronize the Navigation Pane with the Section that is presently active, scrolling it into view
Problem to Solve
When one selects a OneNote Section from among those offered as results in response to a Find in All Notebooks command, that Section is made "Active." The Page (or Sub-Page) that contains the match is likewise displayed and gets the input focus. In addition, this Page (or Sub-Page) gets selected in the Page List pane.
Unfortunately, if you use a vertical OneNote Navigation Pane that hierarchically displays your presently open notebooks, with often only a subset of their potentially vast hierarchies expanded in the Pane's Notebook trees, trees that can become very tall even when only partially expanded, OneNote does not visually synchronize the Navigation Pane with the new Active Section and makes no attempt to vertically scroll it into view. What's worse is the fact that if the Active Section is nested within a collapsed (i.e., closed) Notebook and/or Section Group, the Navigation Pane does expand this container or any likewise collapsed containers that are its ancestors.
In similar fashion, when navigates back through previous Active Sections or forward through that chain, the Navigation Pane does not get synchronized with the Active Section as it changes.
The purpose of making the Active Section visible within the Navigation Pane, rather than only using this pane to select a section, is that this allows one to see the Active Section in context. More specifically, within the context of:
- The hierarchies that are presently displayed within the Navigation Pane
- The set of its sibling Sections that appear both before and after the Active Section, which may be of interest
- Any potential Section Groups that follow all sibling sections of the Active Section, if not too far below, resulting in them falling off-screen, but still readily accessible by then manually scrolling, often only a small amount, in order to reach them
New Feature/Solution
Add a menu item to perform the functionality described above. The italicized words in parentheses are optional: 🔁 Sync Navigation Pane (with Active Section)
..., to an appropriate context menu for the task, probably one that is already modified by this Extension with other useful contextual tasks, as long as it is accessible from the layout described above, with the Navigation Pane visible and positioned vertically to the left or right of the focused page, since in this layout there are no tabs above the focused page and, in fact, the currently Active Section isn't even obvious, unless visible and shown selected in the Navigation Pane.
Alternative Solutions
Manually fish through potentially hundreds of Sections and Section Groups in the Navigation Pane, expanding any collapsed Section Groups along the way, because maybe, just maybe the Active Section is nested within them. This is often a very time consuming process, especially when the hierarchies open in the Navigation Group are very tall and even worse, deeply nested, as well.
Additional Context
No additional context is necessary.
THE FINE PRINT This is a hobby project that I started for myself. I'm happy to take requests and will promise to consider each one carefully but offer no guarantees that I will ultimately agree to their usefulness or have time to implement any of them. If OneNote offers a "close enough" work-around then I will probably reject the request - you've been warned!
Just as a show of hands, if any readers agree with the usefulness of this request, please upvote it and/or add additional comments to this request.
Let me just state right off the bat that, in my humble opinion, general suggestions to make the content of one's notebooks less tall, less deep in terms of nesting, or to have fewer notebooks open at any one time, are not very constructive and do not apply to all potential uses of OneNote as a note-keeping application. Furthermore, the mistaken notion that Section Groups should not be used, that instead Sections could instead be used as logical Section Groups, that Pages could be used as logical Sections, and that Sub-Pages could then take on the role of Pages, is ill-conceived on many fundamental levels. More importantly, it also runs into physical OneNote file layout and unique identification issues, as already mentioned in other posts on the topic of synchronization after changes.
That would be great. Unfortunately, I have no way to control that. Add-ins like OneMore use an API limited to updating the contents of a page or the contents of the notebook/section/page hierarchy. But there are no APIs that can control the OneNote UI itself.
That would be great. Unfortunately, I have no way to control that. Add-ins like OneMore use an API limited to updating the contents of a page or the contents of the notebook/section/page hierarchy. But there are no APIs that can control the OneNote UI itself.
Fortunately, I do have a way to control that, after nearly a decode of non-continuous effort of trying to solve this problem using everything MS has to offer for OneNote control from both inside and outside of the OneNote process, even going so far as to dive into what messages it processes, internally. I can state somewhat definitively at this point, that MS is clearly not interested in adding this synchronization functionality to OneNote, even though the issue has been around for much more than a decade at this point, has been bothersome to countless OneNote users, and all despite the fact that MS has added similar functionality to pretty much every other MS application out there, that has a potentially large tree view with the ability to select items from outside of this control (e.g., via a search or some other mechanism for out-of-tree navigation through the items of the tree, changing its selected item state in the process).
If you would like to integrate this functionality into OneMore, I can provide you with the C# code that implements it. It leverages the MS UI Automation Framework to solve the problem with, at least at present, no dependencies on OneNote interop.
A Small Aside Another tangentially related annoyance present in OneNote's UI is the inability to collapse a Notebook and all Section Groups within the notebook in one fell swoop. If you have a Notebook that is chock-full of expanded section groups, short of closing the notebook and reopening it, there is no non-onerous way to collapse all expanded Section Groups within the Notebook's representation in the Navigation Pane, other than going through each expanded Section Group and individually closing it. The code I wrote can easily be modified to do this programmatically for an entire notebook, or perhaps starting at some Section Group level, as well, since this functionality is only a simple subset of the much more arduous functionality of bringing the Active Section, even if it is not presently logically visible within the partially expanded hierarchy present within the Navigation Pane, into view.
The following is an excerpt from a detailed description of some of the difficulty encountered while trying to solve the task at hand, now that I have a fully working robust solution.
It was very VERY hard to get this functionality to work for more complex cases, especially when one or more collapsed Section Groups lie along the path through the hierarchy from the selected Notebook to a deeply nested Active Section, an Active Section that is hidden within the portion of the hierarchy that is not presently open and therefore cannot be made visible by vertically scrolling the Navigation Pane without first changing some of the hierarchy's initial collapsed/expanded state. This had to be done with no starting knowledge of the actual hierarchical path from the Notebook to the Active Section, as explained in detail below.
What follows is an example of a difficult case. Many issues were encountered wile trying to work through similarly difficult scenarios that required a significant amount of research and subsequent attempts to fix the issues, often resulting in failure on first/second/third... try and then requiring additional research/trial-and-error/etc., until they were resolved.
Example Search (bold text is used to mark the names of the containing Notebook, traversed Section Groups, and the Active Section itself, that are links within the chain to the Active Section [i.e., the path], stand out):
v Some Notebook (not selected, expanded) # Not searched
...
> Another Notebook (not selected, collapsed) # Not searched
v [# Important Notebook #] (selected, initially collapsed) # Left expanded post search
| Section 1 # Nothing to see here
| Section 2 # Empty of content
\v Section Group 1a (initially expanded) # No change to expanded state
| Section 1a.1 # Not it...
> Section Group 2a (collapsed) ... # Expanded, then collapsed
v- Section Group 2b (initially collapsed # Left expanded post search
| Section 2b.1 # Nope...
| Section 2b.1 # Pass...
v- Section Group 3a (initially collapsed) # Left expanded post search
| Section 3.1 # No dice...
| Section 3.2 # Skip...
| [# Section 3.3 #] (selected, Active Section) # Found - search ends
> Section Group 4a (collapsed)
> Section Group 4b (collapsed)
...
A detailed description of the search functionality, when faced with the preceding example is shown below:
Before the Active Section could be made visible, we need to find it in the currently selected Notebook (which happens to be presently collapsed and, somewhat unexpectedly, completely unsearchable in that state and worse yet, lying to us if interrogated via its properties that it is presently empty [!]).
- Expand the selected notebook, Important Notebook, and only then start the search through its descendants (if any)
Skipping over Section 1.1, we reach Section Group 2a and it appears empty, because it is, just like the selected Notebook, Important Notebook, also collapsed. However, unlike the Notebook containing the Active Section (which is marked as selected), intermediate Section Groups do not propagate the selected state of the Active Section, if they contain it, up the hierarchy. In other words, the only hierarchical elements that are selected are the Notebook with the Active Section and the Active Section itself. All elements in between (i.e., any intermediate Section Groups en-route to the Active Section) are not selected and as far as I can tell, having searched far and wide through all available properties and patterns, bear no other indication of the fact that they are an (important) intermediate link within the full Notebook to Active Section chain.
Since we can't tell if the Active Section lies within Section Group 2a, in fact we can't even tell if this Section Group is empty or not, we will have to examine its children (and possibly deeper descendants), but first we will need to expand it to be given the privilege to even attempt to do so.
Note that if we don't find the Active Section in a particular Section Group (or its descendants), such as Section Group 2a, and we expanded it just to be able to peek inside, we will need to be good citizens and collapse it back on our "way out." Not including the historical tracking functionality to do this would likely leave the selected Notebook in a "gratuitously expanded hierarchical mess" up to the Active Section, as (completely unanticipated by the end-user) collateral damage to their potentially only partially expanded initial hierarchy pre-search. We really, REALLY!, don't want to mess with the initial hierarchical expanded/collapsed representation, with one important exception, covered in the last step. So...
-
Expand Section Group 2a and search inside. Since we don't find the Active Section in there, collapse Section Group 2a, on the way out.
-
Expand Section Group 2b and search inside...
As we encounter Section Group 3, we run into the same issue - can't see "Jack" without expanding the Section Group, first
- Expand Section Group 3 and search inside...
Eureka! We found the Active Section, Section 3.3.
- Leave everything that's been left expanded en-route to the Active Section, as is.
- Vertically scroll the Navigation Pane to ensure that the Active Section, Section 3.3, which is definitely logically visible in the hierarchy at this point thanks to the Section Group expansions that have been performed (and left intact) along the way, is also visible on-screen.
@SteelBlueVision Hi, sorry I know this is a couple of months old, but you mentioned you have C# code to automate the UI here? Could you share that please and I'll take a look?
And now it is I who have to apologize - just saw your message. How can I stage it here on GitHub, without using any of my personal repos? Or, is there an alternative?
You could attach a Zip here
In the works over the next couple of weeks (busy at work at the moment).
As mentioned in #1930, this should focus on page as well as section