Tips and tricks for Scintilla Control
How to avoid loosing focus with contextual menus?
You can use your own contextual menus with Scintilla. But some customers had the problem, that focus was lost. If you have that problem, you can simply add a call to GrabFocus method to the ConstructContextualMenu and make sure the focus is set back to the control. The focus can be lost, if the right click brings focus to another control or the window.
Autocomplete not working for unicode characters?
One client noticed, that auto complete in our example didn't work for accented characters. But that one was easily fixed by switching to string functions working on bytes. The accented characters in UTF-8 are multiple bytes and the character functions didn't pick up the right completion. We fixed the example and if needed, you can just copy the code from StartAutoComplete method to update your copy. Now it works fine with ú í á æ þ ö é ð and ý.
Can we wrap long lines instead of scrolling?
If you like to wrap lines, you can change the WrapMode property. You have four choices: kWrapNone for no wrapping, kWrapWord to wrap on word or style boundaries, kWrapWhiteSpace to wrap on white space or kWrapChar to wrap after any character.
Can the control have a border on Windows to look more like TextArea?
We added the HasBorder property in the v22.4 plugin, so you can turn it on. Please do that either in the IDE or in the Prepare event, so it is done before the control is created. Once created, you can't change the border status.
Can I change the color for selected text?
Yes, you can do that with changing the selection fore and back color. For example by using the user's highlight color and then putting in white text color:
How to disable the context menu?
If you like to make your own or have none, you can tell Scintilla to not show one:
Alternatively you can use kPopUpText to only show the menu, when clicking on text.
How to use system font for texts?
Before you define derived styles, you may want to change the common style and put in the system font name:
Dim style As ScintillaStyleMBS = c.Style(ScintillaStyleMBS.kStylesCommonDefault)
// Set font to be system font
style.Font = SystemInformationMBS.SystemFont
Why do I get text with extra NULL byte?
Please update the plugin. Earlier versions had a few bugs, where text properties had either extra NULL bytes or missed a character. That was due the fact that C strings have a NULL byte to mark the end. And the documentation was not always clear which property reports the length with or without the NULL byte.
How do I get a file dropped on the control?
Please check the URIDropped event, which should report the file URL for the file.
Since Scintilla captures the drop, the Drop event from Xojo will not work.
Can we do search and replace with the control?
Yes, please review the newer example project, which shows how to show a search window. Scintilla can perform the search for you in the text and optionally use regular expressions.
What languages can be handled by syntax coloring?
SciTE currently is able to syntax style these languages (* denotes support for folding):
- ANS.1 MIB definition files*
- Assembler (NASM, MASM)
- Batch files (MS-DOS)
- conf (Apache)*
- diff files*
- Flagship (Clipper / XBase)*
- Flash (ActionScript)*
- IDL - both MSIDL and XPIDL*
- INI, properties* and similar
- Intel HEX*
- JSON and JSON-LD
- Modula 3
- Objective C
- Objective Caml*
- Perl, most of it except for some ambiguous cases*
- SORCUS Installation
- Specman E*
- SQL and PLSQL
- TeX and LaTeX
- VB and VBScript*
How can I show my own content over the Scintilla Control?
Since the control draws itself and you like to avoid overdrawing it, we suggest to look into OverlayMBS class for content on top. Please note that you may need to yourself move the overlay with the parent window.
Can I make the control read only?
Yes, we added a ReadOnly property for this. Any changes to the text will be rejected.
Can we do auto indent?
Yes, the example got that added later.
Check the example for the CharacterAdded event, where we detect returns and then add tabs for the next line to match the last line.
How to scroll vertically in code?
Please set the FirstVisibleLine property.