Browse field losing focus

Hello, I have a quantity field, in a freeform browser, and when I double click on this field, without any event being executed afterwards, it loses focus. Please, does anyone know how to solve this case?
 
Hello wich browse are you talking about in your code? Is it "br-itens" ?
Because if it's him in your DBLCLICK triggers your are doing an open-query on him that could explain the lose of your focus:
Code:
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL br-itens wWindow
ON MOUSE-SELECT-DBLCLICK OF br-itens IN FRAME fpage0 /* Itens do Pedido */
DO:
    find user-coml where user-coml.usuario = c-seg-usuario no-lock no-error.
    
    IF AVAIL tt-item AND tt-item.selecionado = '' THEN DO:

        ASSIGN tt-item.selecionado     = '*'.

        RUN pi-valida-item.
        IF RETURN-VALUE = 'OK' THEN DO:
            RUN pi-valida-qtd.

            IF RETURN-VALUE = 'OK' THEN DO:

                ASSIGN linha = br-itens:query:CURRENT-RESULT-ROW.

                br-pedidos:REFRESH().
                {&OPEN-QUERY-br-itens}
                {&OPEN-QUERY-br-itens-sel}

                IF  br-itens:QUERY:NUM-RESULTS > 0 THEN DO:

                    IF br-itens:QUERY:NUM-RESULTS + 1 = linha THEN
                        linha = linha - 1.

                    br-itens:QUERY:REPOSITION-TO-ROW(linha).     

                END.

                ASSIGN i-itens-selec = i-itens-selec + 1.
                DISP i-itens-selec with FRAME fPage0.
                
                /*REPOSITION br-itens TO ROWID ROWID(tt-item) NO-ERROR.*/

            END.
            ELSE
                ASSIGN tt-item.selecionado     = ' '.
        END.
        ELSE
            ASSIGN tt-item.selecionado     = ' '.
        
    END.

    APPLY 'value-changed' TO br-itens.

    APPLY "entry":U to tt-item.qt-a-alocar in BROWSE br-itens.
    RETURN NO-APPLY.

END.
 
Last edited:
Hello wich browse are you talking about in your code? Is it "br-itens" ?
Because if it's him in your DBLCLICK triggers your are doing an open-query on him that could explain the lose of your focus:
Code:
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL br-itens wWindow
ON MOUSE-SELECT-DBLCLICK OF br-itens IN FRAME fpage0 /* Itens do Pedido */
DO:
    find user-coml where user-coml.usuario = c-seg-usuario no-lock no-error.
   
    IF AVAIL tt-item AND tt-item.selecionado = '' THEN DO:

        ASSIGN tt-item.selecionado     = '*'.

        RUN pi-valida-item.
        IF RETURN-VALUE = 'OK' THEN DO:
            RUN pi-valida-qtd.

            IF RETURN-VALUE = 'OK' THEN DO:

                ASSIGN linha = br-itens:query:CURRENT-RESULT-ROW.

                br-pedidos:REFRESH().
                {&OPEN-QUERY-br-itens}
                {&OPEN-QUERY-br-itens-sel}

                IF  br-itens:QUERY:NUM-RESULTS > 0 THEN DO:

                    IF br-itens:QUERY:NUM-RESULTS + 1 = linha THEN
                        linha = linha - 1.

                    br-itens:QUERY:REPOSITION-TO-ROW(linha).    

                END.

                ASSIGN i-itens-selec = i-itens-selec + 1.
                DISP i-itens-selec with FRAME fPage0.
               
                /*REPOSITION br-itens TO ROWID ROWID(tt-item) NO-ERROR.*/

            END.
            ELSE
                ASSIGN tt-item.selecionado     = ' '.
        END.
        ELSE
            ASSIGN tt-item.selecionado     = ' '.
       
    END.

    APPLY 'value-changed' TO br-itens.

    APPLY "entry":U to tt-item.qt-a-alocar in BROWSE br-itens.
    RETURN NO-APPLY.

END.

It would be this one. I commented out the open-query in browse br-itens, but the focus loss continues.
 
Hello wich browse are you talking about in your code? Is it "br-itens" ?
Because if it's him in your DBLCLICK triggers your are doing an open-query on him that could explain the lose of your focus:
Code:
&ANALYZE-SUSPEND _UIB-CODE-BLOCK _CONTROL br-itens wWindow
ON MOUSE-SELECT-DBLCLICK OF br-itens IN FRAME fpage0 /* Itens do Pedido */
DO:
    find user-coml where user-coml.usuario = c-seg-usuario no-lock no-error.
   
    IF AVAIL tt-item AND tt-item.selecionado = '' THEN DO:

        ASSIGN tt-item.selecionado     = '*'.

        RUN pi-valida-item.
        IF RETURN-VALUE = 'OK' THEN DO:
            RUN pi-valida-qtd.

            IF RETURN-VALUE = 'OK' THEN DO:

                ASSIGN linha = br-itens:query:CURRENT-RESULT-ROW.

                br-pedidos:REFRESH().
                {&OPEN-QUERY-br-itens}
                {&OPEN-QUERY-br-itens-sel}

                IF  br-itens:QUERY:NUM-RESULTS > 0 THEN DO:

                    IF br-itens:QUERY:NUM-RESULTS + 1 = linha THEN
                        linha = linha - 1.

                    br-itens:QUERY:REPOSITION-TO-ROW(linha).    

                END.

                ASSIGN i-itens-selec = i-itens-selec + 1.
                DISP i-itens-selec with FRAME fPage0.
               
                /*REPOSITION br-itens TO ROWID ROWID(tt-item) NO-ERROR.*/

            END.
            ELSE
                ASSIGN tt-item.selecionado     = ' '.
        END.
        ELSE
            ASSIGN tt-item.selecionado     = ' '.
       
    END.

    APPLY 'value-changed' TO br-itens.

    APPLY "entry":U to tt-item.qt-a-alocar in BROWSE br-itens.
    RETURN NO-APPLY.

END.

It seems that the loss of focus does not occur because of some event that is being executed, it seems to me that some command, property or configuration of the browse br-itens is causing this.
 
It seems that the loss of focus does not occur because of some event that is being executed, it seems to me that some command, property or configuration of the browse br-itens is causing this.
You also have a part where your are repositioning your focus, just there:

Code:
IF  br-itens:QUERY:NUM-RESULTS > 0 THEN DO:

    IF br-itens:QUERY:NUM-RESULTS + 1 = linha THEN
        linha = linha - 1.

    br-itens:QUERY:REPOSITION-TO-ROW(linha).   

END.
 
Have you tried commenting out the RETURN NO-APPLY?

Yes, I tried. This is the double click trigger code:

DO:
find user-coml where user-coml.usuario = c-seg-usuario no-lock no-error.

IF AVAIL tt-item AND tt-item.selecionado = '' THEN DO:

ASSIGN tt-item.selecionado = '*'.

RUN pi-valida-item.
IF RETURN-VALUE = 'OK' THEN DO:
RUN pi-valida-qtd.

IF RETURN-VALUE = 'OK' THEN DO:

/*ASSIGN linha = br-itens:query:CURRENT-RESULT-ROW.*/

br-pedidos:REFRESH().
/*{&OPEN-QUERY-br-itens}*/
{&OPEN-QUERY-br-itens-sel}

IF br-itens:QUERY:NUM-RESULTS > 0 THEN DO:

IF br-itens:QUERY:NUM-RESULTS + 1 = linha THEN
linha = linha - 1.

/*br-itens:QUERY:REPOSITION-TO-ROW(linha). */

END.

ASSIGN i-itens-selec = i-itens-selec + 1.
DISP i-itens-selec with FRAME fPage0.

/*REPOSITION br-itens TO ROWID ROWID(tt-item) NO-ERROR.*/

END.
ELSE
ASSIGN tt-item.selecionado = ' '.
END.
ELSE
ASSIGN tt-item.selecionado = ' '.

END.

/*APPLY 'value-changed' TO br-itens.*/

APPLY "entry":U to tt-item.qt-a-alocar in BROWSE br-itens.
/*RETURN NO-APPLY.*/

END.
 
Yes, I tried. This is the double click trigger code:

DO:
find user-coml where user-coml.usuario = c-seg-usuario no-lock no-error.

IF AVAIL tt-item AND tt-item.selecionado = '' THEN DO:

ASSIGN tt-item.selecionado = '*'.

RUN pi-valida-item.
IF RETURN-VALUE = 'OK' THEN DO:
RUN pi-valida-qtd.

IF RETURN-VALUE = 'OK' THEN DO:

/*ASSIGN linha = br-itens:query:CURRENT-RESULT-ROW.*/

br-pedidos:REFRESH().
/*{&OPEN-QUERY-br-itens}*/
{&OPEN-QUERY-br-itens-sel}

IF br-itens:QUERY:NUM-RESULTS > 0 THEN DO:

IF br-itens:QUERY:NUM-RESULTS + 1 = linha THEN
linha = linha - 1.

/*br-itens:QUERY:REPOSITION-TO-ROW(linha). */

END.

ASSIGN i-itens-selec = i-itens-selec + 1.
DISP i-itens-selec with FRAME fPage0.

/*REPOSITION br-itens TO ROWID ROWID(tt-item) NO-ERROR.*/

END.
ELSE
ASSIGN tt-item.selecionado = ' '.
END.
ELSE
ASSIGN tt-item.selecionado = ' '.

END.

/*APPLY 'value-changed' TO br-itens.*/

APPLY "entry":U to tt-item.qt-a-alocar in BROWSE br-itens.
/*RETURN NO-APPLY.*/

END.

One detail, when I run the program through the App Builder, this problem does not occur.
 

patelspam

New Member
Hey there!
Try removing/commenting the trigger and try to double-click the browse the same way. If it still loses focus then there's probably nothing wrong with the trigger. Let us know how it goes
 
Top