FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour TGet bLostFocus yWHEN no entiendo bien la l贸gica[SOLUCIONADO
Posts: 309
Joined: Wed Mar 28, 2018 04:38 PM

Re: TGet bLostFocus y WHEN no entiendo bien la l贸gica...

Posted: Mon Oct 24, 2022 05:20 PM
He revisado el c贸digo con los botones y si a los controles del bot贸n le a帽ades el bLostFocus, el resultado es el mismo.

c贸digo:
Code (fw): Select all Collapse
#include 'fivewin.ch'

static clogfile := 'log.txt'

Function Main()

聽 聽 Local oDlg 聽:= Nil
聽 聽 Local oFld 聽:= Nil
聽 聽 Local oGet1a := Nil
聽 聽 Local oGet1b := Nil
聽 聽 Local oGet2a := Nil
聽 聽 Local oGet2b := Nil
聽 聽 Local oBt1, oBt2
聽 聽 Local cVar1a := 'XXXXXXXXXX'
聽 聽 Local cVar1b := 'XXXXXXXXXX'
聽 聽 Local cVar2a := 'XXXXXXXXXX'
聽 聽 Local cVar2b := 'XXXXXXXXXX'
聽 聽
聽 聽 ferase( cLogFile )

聽 聽 TGet():lClrFocus := .T.

聽 聽 DEFINE DIALOG oDlg TITLE "Test bLostFocus in Folder" ;
聽 聽 聽 聽 FROM 5, 5 TO 20, 49

聽 聽 @ 0.5, 1 FOLDER oFld PROMPT "one", "Two" ;
聽 聽 聽 聽 OF oDlg SIZE 160, 90
聽 聽 @ 3,1 BUTTON oBt1 PROMPT "OK" OF oFld:aDialogs[1] 聽 聽 聽 聽 聽 聽 聽
聽 聽 聽 聽 聽 聽 聽 聽 聽oBt1:bLostFocus := {|| Write('FOLDER 1 BOTON 1')}

聽 聽 @ 1, 1 GET oGet1a VAR cVar1a OF oFld:aDialogs[1] PICTURE '@S20' SIZE 40,10
聽 聽 聽 聽 聽 聽 聽 聽oGet1a:bLostFocus := {|| Write('FOLDER 1 GET 1')}

聽 聽 @ 2, 1 GET oGet1b VAR cVar1b OF oFld:aDialogs[1] PICTURE '@S20' SIZE 40,10
聽 聽 聽 聽 聽 聽 聽 聽oGet1b:bLostFocus := {|| Write('FOLDER 1 GET 2')}
聽 聽
聽 聽 @ 3,1 BUTTON oBt2 PROMPT "OK" OF oFld:aDialogs[2] 聽
聽 聽 聽 聽 聽 聽 聽 聽 聽oBt2:bLostFocus := {|| Write('FOLDER 1 BOTON 2')}

聽 聽 @ 1, 1 GET oGet2a VAR cVar2a OF oFld:aDialogs[2] PICTURE '@S20' SIZE 40,10
聽 聽 聽 聽 聽 聽 聽 聽oGet2a:bLostFocus := {|| Write('FOLDER 2 GET 1')}

聽 聽 @ 2, 1 GET oGet2b VAR cVar2b OF oFld:aDialogs[2] PICTURE '@S20' SIZE 40,10
聽 聽 聽 聽 聽 聽 聽 聽oGet2b:bLostFocus := {|| Write('FOLDER 2 GET 2')}
聽 聽 聽 聽 聽 聽 聽

聽 聽 ACTIVATE DIALOG oDlg CENTERED ON INIT oBt1:SetFocus()

Return ( Nil )

Static Function Write( cText )

聽 聽 hb_MemoWrit( cLogFile, hb_MemoRead( cLogFile ) + hb_eol() + Time() + ' ' + cText)

Return ( Nil )


resultado del log:
Code (fw): Select all Collapse
19:18:26 FOLDER 1 BOTON 1
19:18:26 FOLDER 1 BOTON 1
19:18:26 FOLDER 1 BOTON 2
19:18:26 FOLDER 1 BOTON 2
19:18:31 FOLDER 1 BOTON 1
--------

驴 Y porque no ?

驴 And why not ?
Posts: 309
Joined: Wed Mar 28, 2018 04:38 PM

Re: TGet bLostFocus y WHEN no entiendo bien la l贸gica...

Posted: Tue Oct 25, 2022 07:04 AM
continuando con las pruebas, con TFolderEx el comportamiento es el mismo ( creo que es err贸neo ) ya que ejecuta "algunos" bLostFocus cuando crea el di谩logo. Bajo mi parecer, creo que primero crea los di谩logos, en cada di谩logo se asigna el foco en el primer control, luego crea el control del folder y "sale" de cada control de los di谩logos ejecutando el bLostFocus correspondiente.

He realizado la prueba con un di谩logo sin folders para salir de dudas y funciona correctamente:
Code (fw): Select all Collapse
#include 'fivewin.ch'

static clogfile := 'log.txt'

Function Main()

聽 聽 Local oDlg 聽:= Nil
聽 聽 Local oGet1a := Nil
聽 聽 Local oGet1b := Nil
聽 聽 Local cVar1a := 'XXXXXXXXXX'
聽 聽 Local cVar1b := 'XXXXXXXXXX'
聽 聽
聽 聽 ferase( cLogFile )

聽 聽 TGet():lClrFocus := .T.

聽 聽 DEFINE DIALOG oDlg TITLE "Test bLostFocus in Folder" ;
聽 聽 聽 聽 FROM 5, 5 TO 20, 49

聽 聽 @ 1, 1 GET oGet1a VAR cVar1a OF oDlg PICTURE '@S20' SIZE 40,10
聽 聽 聽 聽 聽 聽 聽 聽oGet1a:bLostFocus := {|| Write('FOLDER 1 GET 1')}

聽 聽 @ 2, 1 GET oGet1b VAR cVar1b OF oDlg PICTURE '@S20' SIZE 40,10
聽 聽 聽 聽 聽 聽 聽 聽oGet1b:bLostFocus := {|| Write('FOLDER 1 GET 2')}
聽 聽
聽 聽 ACTIVATE DIALOG oDlg CENTERED 

Return ( Nil )

Static Function Write( cText )

聽 聽 hb_MemoWrit( cLogFile, hb_MemoRead( cLogFile ) + hb_eol() + Time() + ' ' + cText)

Return ( Nil )


En este caso, si no se pulsa nada, no aparece nada en el log.

Hay alguna forma ( sin tener que dar muchos rodeos ) de evitar que se ejecuten los blosfocus de los controles cuando se monta un di谩logo con Folders?

Gracias y salud!
--------

驴 Y porque no ?

驴 And why not ?
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM

Re: TGet bLostFocus y WHEN no entiendo bien la l贸gica...

Posted: Tue Oct 25, 2022 07:09 AM

Estimado Victor,

Has probado a asignar los bLostFocus desde la cla煤sula ON INIT del di谩logo principal ?

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 309
Joined: Wed Mar 28, 2018 04:38 PM

Re: TGet bLostFocus y WHEN no entiendo bien la l贸gica...

Posted: Tue Oct 25, 2022 07:38 AM
Antonio Linares wrote:Estimado Victor,

Has probado a asignar los bLostFocus desde la cla煤sula ON INIT del di谩logo principal ?


Hola Antonio.
He probado en el INIT y con bStart.

El resultado del INIT con este c贸digo:
Code (fw): Select all Collapse
#include 'fivewin.ch'

static clogfile := 'log.txt'

Function Main()

聽 聽 Local oDlg 聽:= Nil
聽 聽 Local oFld 聽:= Nil
聽 聽 Local oGet:=Array(4)
聽 聽 Local cVar1a := 'XXXXXXXXXX'
聽 聽 Local cVar1b := 'XXXXXXXXXX'
聽 聽 Local cVar2a := 'XXXXXXXXXX'
聽 聽 Local cVar2b := 'XXXXXXXXXX'
聽 聽
聽 聽 ferase( cLogFile )

聽 聽 TGet():lClrFocus := .T.

聽 聽 DEFINE DIALOG oDlg TITLE "Test bLostFocus in Folder" ;
聽 聽 聽 聽 FROM 5, 5 TO 20, 49

聽 聽 @ 0.5, 1 FOLDER oFld PROMPT "one", "Two" ;
聽 聽 聽 聽 OF oDlg SIZE 160, 90

聽 聽 @ 1, 1 GET oGet[1] VAR cVar1a OF oFld:aDialogs[1] PICTURE '@S20' SIZE 40,10

聽 聽 @ 2, 1 GET oGet[2] VAR cVar1b OF oFld:aDialogs[1] PICTURE '@S20' SIZE 40,10
聽 聽
聽 聽 @ 1, 1 GET oGet[3] VAR cVar2a OF oFld:aDialogs[2] PICTURE '@S20' SIZE 40,10

聽 聽 @ 2, 1 GET oGet[4] VAR cVar2b OF oFld:aDialogs[2] PICTURE '@S20' SIZE 40,10

聽 聽 ACTIVATE DIALOG oDlg CENTERED ON INIT Start(oGet)

Return ( Nil )

Static Function Start(oGet)

聽 聽 oGet[1]:bLostFocus := {|| Write('FOLDER 1 GET 1')}
聽 聽 oGet[2]:bLostFocus := {|| Write('FOLDER 1 GET 2')}
聽 聽 oGet[3]:bLostFocus := {|| Write('FOLDER 2 GET 1')}
聽 聽 oGet[4]:bLostFocus := {|| Write('FOLDER 2 GET 2')}

Return ( Nil )

Static Function Write( cText )

聽 聽 hb_MemoWrit( cLogFile, hb_MemoRead( cLogFile ) + hb_eol() + Time() + ' ' + cText)

Return ( Nil )


es este:
Code (fw): Select all Collapse
09:29:55 FOLDER 2 GET 1


por lo que deduzco que despu茅s de montar el segundo di谩logo del folder, se queda el foco en el primer get que se monta del di谩logo 2 y cuando muestra la ventana se sit煤a en el primer di谩logo y entonces ejecuta el blostfocus

en cambio con el bStart el comportamiento es correcto. Con este c贸digo:
Code (fw): Select all Collapse
#include 'fivewin.ch'

static clogfile := 'log.txt'

Function Main()

聽 聽 Local oDlg 聽:= Nil
聽 聽 Local oFld 聽:= Nil
聽 聽 Local oGet:=Array(4)
聽 聽 Local cVar1a := 'XXXXXXXXXX'
聽 聽 Local cVar1b := 'XXXXXXXXXX'
聽 聽 Local cVar2a := 'XXXXXXXXXX'
聽 聽 Local cVar2b := 'XXXXXXXXXX'
聽 聽
聽 聽 ferase( cLogFile )

聽 聽 TGet():lClrFocus := .T.

聽 聽 DEFINE DIALOG oDlg TITLE "Test bLostFocus in Folder" ;
聽 聽 聽 聽 FROM 5, 5 TO 20, 49

聽 聽 @ 0.5, 1 FOLDER oFld PROMPT "one", "Two" ;
聽 聽 聽 聽 OF oDlg SIZE 160, 90

聽 聽 @ 1, 1 GET oGet[1] VAR cVar1a OF oFld:aDialogs[1] PICTURE '@S20' SIZE 40,10

聽 聽 @ 2, 1 GET oGet[2] VAR cVar1b OF oFld:aDialogs[1] PICTURE '@S20' SIZE 40,10
聽 聽
聽 聽 @ 1, 1 GET oGet[3] VAR cVar2a OF oFld:aDialogs[2] PICTURE '@S20' SIZE 40,10

聽 聽 @ 2, 1 GET oGet[4] VAR cVar2b OF oFld:aDialogs[2] PICTURE '@S20' SIZE 40,10

聽 聽 oDlg:bStart:={||Start(oGet)}

聽 聽 ACTIVATE DIALOG oDlg CENTERED

Return ( Nil )

Static Function Start(oGet)

聽 聽 oGet[1]:bLostFocus := {|| Write('FOLDER 1 GET 1')}
聽 聽 oGet[2]:bLostFocus := {|| Write('FOLDER 1 GET 2')}
聽 聽 oGet[3]:bLostFocus := {|| Write('FOLDER 2 GET 1')}
聽 聽 oGet[4]:bLostFocus := {|| Write('FOLDER 2 GET 2')}

Return ( Nil )

Static Function Write( cText )

聽 聽 hb_MemoWrit( cLogFile, hb_MemoRead( cLogFile ) + hb_eol() + Time() + ' ' + cText)

Return ( Nil )


no se ejecuta ning煤n blostfocus salvo que se salga por el usuario.

Pero es un poco engorroso configurarlo as铆, ya que separas la definici贸n del get con la asignaci贸n del codelblock

Gracias por tu tiempo.
--------

驴 Y porque no ?

驴 And why not ?
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM

Re: TGet bLostFocus y WHEN no entiendo bien la l贸gica...

Posted: Tue Oct 25, 2022 09:41 AM

Estimado Victor,

Es que las p谩ginas del folder se van construyendo una a una y es normal que se evaluen los bLostFocus

En cambio desde bStart como muy bien has comprobado, el problema queda resuelto

Se que es engorroso pero no creo que haya otra soluci贸n

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 309
Joined: Wed Mar 28, 2018 04:38 PM

Re: TGet bLostFocus y WHEN no entiendo bien la l贸gica...

Posted: Tue Oct 25, 2022 10:04 AM
Antonio Linares wrote:Estimado Victor,

Es que las p谩ginas del folder se van construyendo una a una y es normal que se evaluen los bLostFocus

En cambio desde bStart como muy bien has comprobado, el problema queda resuelto

Se que es engorroso pero no creo que haya otra soluci贸n


Gracias Antonio por tu respuesta, como dices no es lo m谩s correcto pero al menos est谩 detectado y vemos una forma limpia de solventarlo por si otro usuario llega por aqu铆.
--------

驴 Y porque no ?

驴 And why not ?

Continue the discussion