[wxPython-users] how to set focus (to an editor) ?

Robin Dunn robin at alldunn.com
Sat Jun 2 09:35:29 PDT 2007


Stef Mientki wrote:
> hello,
> 
> I'm using a Scintilla editor to show the active code in a simulation.
> Now I'm not familiar with Scintilla at all,
> and as for the moment I use just a few options of Scintilla,
> and the manual is so huge  ...
> ... I can't find a method to keep focus on the editor.
> 
> So in general is there a command to set focus to a visual component ?
> 
> And specific for Scintilla,
> I use these settings
>   Code_Editor.SetCaretLineBack("BLUE")
>   Code_Editor.SetCaretLineVisible(True)
>   Code_Editor.GotoLine(Active_LineNumber)
> and as long as the editor (and application) has focus, the active line 
> is nicely highlighted.
>  From Delphi I'm used, that most components can keep the active 
> highligting, even when object / application looses focus,
> by setting a special flag of that component.
> But I can't find such a flag within Scintilla.
> I've tried
>      STCFocus(True)
>      GetSTCFocus()
> but both of them crashes.

Does it crash or just give an exception?  Using SetSTCFocus seems to be 
working for me.  Combining that with some handlers for EVT_KILL_FOCUS 
and EVT_SET_FOCUS should do the trick.


> Anyone has a good idea ?

You can also specify a marker that instead of drawing a symbol in the 
margin does a line highlight.  You could then use that to highlight 
lines, once the marker has been set for a line it will stay there 
regardless of focus until you remove it.

-- 
Robin Dunn
Software Craftsman
http://wxPython.org  Java give you jitters?  Relax with wxPython!





More information about the wxpython-users mailing list