Introduction
Often, the navigation of documents in note-taking applications is made in the form of links (Link), which the user creates manually in each document. But what if you do keyword navigation without using unique links in the document?
The task that I set myself when improving the functionality of the FAQ.Net program was to create a convenient mechanism for navigating RTF documents in the FAQ.Net application.
As a result,
FAQ.Net version 2.7 acquired a tooltip function using custom keywords and their definition.
What are their advantages and benefits in the notes program and how to use them I will briefly describe in the framework of this article.

Ways to create navigation in RTF documents using the standard RichTextBox component
- Using bookmarks
In the RTF standard, there is a built-in bookmarking mechanism, but the standard RichTextBox component does not support the operation of the bkmkstart and bkmkend elements. - Disable the DetectUrls property and create your own links.
This method is described in the article Links with arbitrary text in a RichTextBox . In this case, you need to add code to determine the URLs and restore all links when opening an RTF document. I thought that this is time-consuming and will slightly reduce the speed of the application. - Tooltips
After the two methods described above, I read an article about tooltips in the RichTextBox [WinForms] component RichTextBox ToolTip like Visual-Studio's . This option was taken as a basis.
Tooltips Task list
In the idea with tooltips, I saw the potential for the desired result and began to realize it. All that was needed was to expand the tooltip component and add links with transitions to it. There was no ready-made solution in the vast Internet, so I developed the code myself.
List of tasks to be completed:
- organize storage of keywords (hints) with links
- implement the function of determining a word when you hover over it
- create an interface for creating and editing a “dictionary of prompts” (see description below)
- create the ability to quickly create keywords in an RTF document using the "hint dictionary"
- tooltip functionality must be extensible
Item Details
- Keywords are stored inside the SQLite database. Table creation script:
CREATE TABLE word_tooltip ( id_content INTEGER NOT NULL, word VARCHAR NOT NULL, tooltip_type INTEGER NOT NULL, comment VARCHAR NOT NULL, url_adr VARCHAR NULL, group_name VARCHAR NULL, fore_color VARCHAR NULL, create_date DATETIME DEFAULT (CURRENT_TIMESTAMP), modif_date DATETIME, PRIMARY KEY (id_content, word) )
- the function of determining a word when hovering over it is performed using the standard functions of the RichTextBox component: GetPositionFromCharIndex and GetCharIndexFromPosition.
Symbols by which the beginning or end of a word is determined:
',',';',':','!','?','%','+','=','*','$','\'','\"','<','>','^','(',')','[',']','{','}','°','&','|',' ','\n','"','\t'
- “Hint dictionary” - that’s what I called a panel in which all user-created words are displayed and edited, on which you need to display hints when you hover over an RTF document. Panel "Dictionary of tips" consists of:
- control buttons: create, edit, copy and delete.
- search bar
- a panel of words in the form of a tree (TreeView)
- editing panels
- Creating words in the "dictionary of prompts" is performed by pressing Ctrl + Space. If you place the cursor in the middle of the word, then when you call Ctrl + Space, the word filter will be automatically set to the word filter in the help dictionary at the beginning of the word before the cursor, and when you select a word (Enter or double-click), the whole word is replaced with the selected one. As you press letters on the keyboard, the user is shown a filter word at the top of the word selection component. For the convenience of working with the dictionary, when you hover over a word, a hint is displayed inside the filtered list.



- extension of the tooltip functionality is in the tooltip_type INTEGER NOT NULL field. Types of tooltips:
- with reference to the note (internal RTF document). Only the ID of the note (question) is indicated. When hovering over a word, the name of the note is displayed as a hint.
- with reference to the Internet resource. The URL and the hint text are provided.
- static hint. Only the hint text is indicated.
Advantages
- storage and modification of keywords with links in a structured form (table)
- navigation through RTF documents, without changing the documents themselves
- the ability to autocomplete words (IntelliSense) from a dictionary defined by the user
- quick creation and change of links in all documents where there is a keyword
disadvantages
- The problem with RTF tables. Unfortunately, the standard RichTextBox component has a drawback with displaying tables. To eliminate this drawback, the Msftedit.dll library is used, which introduces bugs into the GetPositionFromCharIndex and GetCharIndexFromPosition functions. I don’t know how to deal with this problem yet, but I hope that a solution will be found. In this regard, in the version of FAQ.Net 2.7 I do not recommend using tooltips inside and after RTF tables.
- The morphology of words, i.e. Each word must be duplicated with a new hint.
What will improve further in the FAQ.Net application?
- The function to import / export a dictionary of tips will be added
- You will be able to add tags to notes. In addition, it will add the ability to enter your dictionary of tips for tags.
For example: create a C # tag, create keywords of the desired color. After that, create a syntax highlighting function for the selected fragment. This will allow the user to enter their words and define their highlight words.
Conclusion
In general, I really like the functionality. I believe that the goal of navigating among RTF documents inside the
FAQ.Net application
has been achieved.
In personal use, I keep tooltips as a translator, which helps me in learning and remembering new foreign words.
You can easily store and display hints for abbreviations in the dictionary.
The dictionary is convenient to store links to articles from the Internet and accompany a brief comment.
Attached article links
Video presentation of tooltips in FAQ.NetDetailed description of the application FAQ.NetVkontakte communityDownload Windows application FAQ.Net (free):
(x64)
yadi.sk/d/sq3g4NOD3Zt7ZY(x86)
yadi.sk/d/NKXeyUWH3Zt8PQ