Página 1 de 1

IDEEditor - how to focus?

Publicado: Mié Nov 10, 2021 3:37 am
por Hurricane
Hi,

after opening a file in the editor, how to give focus to the editor?
I found the method in the documentation, but it didn't work.

Código: Seleccionar todo

METHOD BtnOkClick( oSender ) CLASS TFrmVPF
   ....
   ::Close()
   ::oPlugin:IEditor:SetFocused() // does not work
   RETURN Nil
If I have a Form open in Designer, I press CTRL+F12 to show my "View Forms Project" window to select a file, it is opened in Editor, but Form Designer remains in front.
in the image, the file is active, but the editor is not in focus.
If you open a file via Project Manager, the Editor is in focus.
IDEEDITOR_FOCUS.png
IDEEDITOR_FOCUS.png (33.68 KiB) Visto 2685 veces

Re: IDEEditor - how to focus?

Publicado: Mié Nov 10, 2021 1:06 pm
por ignacio

Código: Seleccionar todo

#define SCI_GRABFOCUS         2400
..      
 WITH OBJECT oCode:oCodeEditor1
   :PostMsg( WM_SETFOCUS, 0, 0 )
   :PostMsg( SCI_GRABFOCUS, 0, 0 )
END WITH

Re: IDEEditor - how to focus?

Publicado: Mié Nov 10, 2021 7:20 pm
por Hurricane
Please, what is the complete information?
where do I find the TCODE instance? (when the editor is not in focus)

msgInfo(::IProjectMan:oActiveForm:classname) // TCode (I found :oCodeEditor1) - When Editor is in focus
msgInfo(::IProjectMan:oActiveForm:classname) // TFormEditor - When FormDesigner is in focus

it worked, but it's ugly:

Código: Seleccionar todo

   // ::IEditor:SetFocused() // not work, Topic: https://forum.xailer.com/viewtopic.php?p=55666#p55666
   IF (nPos:=AScan( Application:aForms, {|o| Upper(o:CLASSNAME) == 'TCODE' } )) > 0
      WITH OBJECT Application:aForms[nPos]
        :PostMsg( WM_SETFOCUS, 0, 0 )
        :PostMsg( SCI_GRABFOCUS, 0, 0 )

      END WITH
   ENDIF
ignacio escribió: Mié Nov 10, 2021 1:06 pm

Código: Seleccionar todo

#define SCI_GRABFOCUS         2400
..      
 WITH OBJECT oCode:oCodeEditor1
   :PostMsg( WM_SETFOCUS, 0, 0 )
   :PostMsg( SCI_GRABFOCUS, 0, 0 )
END WITH

Re: IDEEditor - how to focus?

Publicado: Mié Nov 10, 2021 7:59 pm
por jfgimenez
Hi,

try:

Código: Seleccionar todo

::oPlugin:GetProjectMan():ToggleForm()

Re: IDEEditor - how to focus?

Publicado: Mié Nov 10, 2021 10:28 pm
por Hurricane
Hello,

it doesn't work either (and it gets worse, it will affect the Designer).
I have emailed a small complete example.

thanks,
jfgimenez escribió: Mié Nov 10, 2021 7:59 pm

Código: Seleccionar todo

::oPlugin:GetProjectMan():ToggleForm()

Re: IDEEditor - how to focus?

Publicado: Jue Nov 11, 2021 10:19 am
por ignacio

Código: Seleccionar todo

#define SCI_GRABFOCUS         2400
..      
   handle :=  ::GetEditor():Handle
   PostMessage( handle, WM_SETFOCUS, 0, 0 )
   PostMessage( handle, SCI_GRABFOCUS, 0, 0 )

Re: IDEEditor - how to focus?

Publicado: Jue Nov 11, 2021 11:40 am
por Hurricane
worked, thanks.
ignacio escribió: Jue Nov 11, 2021 10:19 am

Código: Seleccionar todo

#define SCI_GRABFOCUS         2400
..      
   handle :=  ::GetEditor():Handle
   PostMessage( handle, WM_SETFOCUS, 0, 0 )
   PostMessage( handle, SCI_GRABFOCUS, 0, 0 )