Open lintalist opened 6 years ago
What's different in the demo now than before is that the settings array is no longer .clone()
ed before being passed to new RichCode()
(https://github.com/G33kDude/RichCode.ahk/commit/0038cb87fe0d5c1b677b8042daae732abe9e38c5#diff-f8eef6ba00f60b536f13c9aa431113e7). Because arrays are always passed by reference, creating two RichCodes without cloning means changing settings for one changes them both, since they're both pointing to the same array in memory.
When you're only using one RichCode it's unnecessary to clone which is why I removed it, though maybe it'd be better to show using multiple in the demo. Thoughts?
Thanks, I thought I'd experimented with adding/removing .Clone()
but the 1.1.27.01 bug got in the way I think . Indeed using .Clone()
resolves the issue. (I'll use three edit controls in my "editor" GUI).
Adding a simple note to the readme.md would be enough I think:
Multiple controls
If you want to use multiple RichCode controls which share the basic settings (fonts, colors etc) use the .Clone()
method when adding a new control:
; Add the RichCode
RC1 := new RichCode(Settings.Clone(), "xm w640 h270")
RC2 := new RichCode(Settings.Clone(), "xm xp w640 h270")
; ....
In the previous version I could add multiple controls in one GUI and set the "language" for each control, which worked well. With this version, it seems it only remembers the last "language" (the most recently added control).
If you type something (just hitting enter will do) in the first control it changes the HTML highlighting to AHK highlighting (you see the colors change or just type something like 'this' for example to see it, this being a "flow". A modified
Examples\demo2.ahk
to illustrate: (I didn't bother to update to block/unblock code, I did change theChangeLang:
label)