Hello!
I am currently writing a simple text editor (for practicing purposes) which includes keyword highlighting. As always the MacOS version runs my highlighting methods as smoothly as expected, but the Windows version caused me some trouble.
At first I had a lot of “jumping” and flickering of my TextArea (a subclass of Xojo’s TextArea class) while editing if keyword highlighting was enabled. Then I modified the subclass with the declares I found in this forum, which (almost) stopped the flickering of my TextArea but caused a lot of flickering of the app icon in the task bar. After modifying the declare methods so that they stop/restart redrawing of just the TextArea instead of the whole window, the flickering went away.
The code now looks like this (triggered in the TextChanged event of my TextArea):
[code]If Highlight.CurrentFile <> Nil And Not IsPlain Then
#If TargetWindows
Me.Freeze
Dim pos As Integer = Me.ScrollPosition
#EndIf
// calling some highlighting methods
#If TargetWindows
Me.ScrollPosition = pos
Me.UnFreeze
Me.Invalidate(False)
#Endif
End If[/code]
But there is one problem left: Usually if you type, the mouse cursor disappears while typing and reappears, if you move the mouse. But (due to the declares, as it seems) the mouse cursor remains to be seen while typing, which wouldn’t be so annoying, if it wouldn’t flicker like the rest of the window did before.
I tried the following workarounds:
- I called “System.Cursors.Hide” at the end of the above method after invalidating the TextArea; the cursor disappeared, but it didn’t reappear again.
- Adding a call of “System.Cursors.Show” in the MouseMove event of the TextArea made the cursor visible (and flicker) all the time again (although I didn’t move the mouse).
- Finally I saved the MouseX and MouseY coordinates to properties when starting my highlighting method and added an if clause to the MouseMove event to show the cursor only if the x and y coordinates differed from the properties (i. e. if the mouse was actually moved). Still the cursor remained all the time although the mouse wasn’t moved.
Could you think of any other way to make the cursor temporarilly unseen? (I cannot think of any way to stop the cursor from flickering, which would be sufficient )