Visible caret when not focused

SyntaxEditor for Silverlight Forum

Posted 13 years ago by Leon Zhou
Avatar
Hi,

I have to complement the syntax editor first, it is an amazing control, excellent work!

I'd like to know if there is a way to have the caret visible when the editor is out of focus. This is particularly useful for implementing dropping to the editor, notifying users where exactly they are dropping.

It's easy to set the caret's position using the existing SyntaxEditor.HitTest method, but the editor is not focused when dragging an external UI element to the editor, therefore the caret is always not visible.

Cheers,

Leon

[Modified at 05/23/2011 07:10 AM]

Comments (5)

Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Leon,

The Caret object has SuspendBlinking() and ResumeBlinking() methods you can call. The SuspendBlinking() call takes a bool indicating whether the caret should display or not. So you could probably pass true to show it and then false later (if the control isn't focused) to hide it again. Or call ResumeBlinking if the control has focus again.


Actipro Software Support

Posted 13 years ago by Leon Zhou
Avatar
Thanks for the prompt reply. I've tried the SuspendBlinking method, but realised that the caret is not shown when the editor is not focused regardless whether the blinking is suspended or not. Blinking is automatically resumed when the editor gains focus again.
Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Leon,

Hmmm, you are correct. There appears to be a line in the EditorView code that prevents the caret from showing up if the control doesn't have focus.

It looks like Silverlight's drag/drop functionality is still limited to file drops. Were you intending to use a custom drag/drop manager here? If so, what sort of content were you intending to move? We do plan on adding drag/drop support within the editor itself eventually.


Actipro Software Support

Posted 13 years ago by Leon Zhou
Avatar
I have several options in Silverlight to do drag and drop: the Silverlight Toolkit DragDropTarget controls, the Telerik DragAndDropManager, and the C1 DragAndDropManager. At the end of day, I intended to allow users drop some sort of code snippet object into the editor, just like dropping a control from the toolbox windows to the code windows in visual studio.
Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Leon,

Yes the problem here is that there could be several views (in the WPF version, not the SL version but they share the same codebase) and we need to ensure the current view is the one with focus so that we don't see carets in all the views when SyntaxEditor gets focus. So I'm not thinking we can really alter our logic that is preventing it from showing when not focused.

That being said, I thought of an alternative. We have a very rich adornments framework in the product. You could make an adornment layer for showing a faux caret while your drag operation is active. There are several samples on making adornments. The smoke text one might be a good starting point for this. Just make a custom adornment layer and render a caret rectangle at the appropriate location. Then remove the adornment layer once the drag ends or leaves the SyntaxEditor.


Actipro Software Support

The latest build of this product (v18.1 build 0233) was released 4 years ago, which was after the last post in this thread.