FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour problems with radio and radioitem
Posts: 88
Joined: Wed Apr 28, 2010 06:34 PM
problems with radio and radioitem
Posted: Tue Jul 14, 2015 03:11 PM
Guys ... I'm tweaking some functions and realized that the radio (standing inside a folder, in a dialog works correctly) to choose an option passes twice in the function, and this is causing me slowly to select the records because two processes times the while, is to fix this?

working example:
Code (fw): Select all Collapse
DEFINE DIALOG oDlg FROM 0,0 TO 520,820 PIXEL
 
  @ 000,195 GROUP TO 045,335 LABEL "Tipo do Relatório" PIXEL TRANSPARENT OF oDlg
  @ 007,195 RADIO oTipo VAR nTipo PROMPT "Tabela de Preço", "Tabela de Promoção", "Lista de Compra", "Lista de Compra Ideal" SIZE 65,9 PIXEL ON CHANGE Troca() OF oDlg
  @ 007,265 RADIOITEM "Sugestão de Compra" RADIOMENU oTipo SIZE 65,08 PIXEL OF oDlg
  @ 016,265 RADIOITEM "Estoque Mínimo" RADIOMENU oTipo SIZE 65,08 PIXEL OF oDlg
  @ 025,265 RADIOITEM "Estoque Negativo" RADIOMENU oTipo SIZE 65,08 PIXEL OF oDlg
  @ 034,265 RADIOITEM "Estoque Positivo" RADIOMENU oTipo SIZE 65,08 PIXEL OF oDlg
 
 ACTIVATE DIALOG oDlg CENTER
 
RETURN NIL


example with problem
Code (fw): Select all Collapse
DEFINE DIALOG oDlg FROM 0,0 TO 520,820 PIXEL
 
  @ 90,03 FOLDER oFld OF oDlg PROMPT "&Produto","&Movimentação","&Valores" ;
    PIXEL SIZE 405,208
 
  @ 000,195 GROUP TO 045,335 LABEL "Tipo do Relatório" PIXEL TRANSPARENT OF oFld:aDialogs[1]
  @ 007,195 RADIO oTipo VAR nTipo PROMPT "Tabela de Preço", "Tabela de Promoção", "Lista de Compra", "Lista de Compra Ideal" SIZE 65,9 PIXEL ON CHANGE Troca() OF oFld:aDialogs[1]
  @ 007,265 RADIOITEM "Sugestão de Compra" RADIOMENU oTipo SIZE 65,08 PIXEL OF oFld:aDialogs[1]
  @ 016,265 RADIOITEM "Estoque Mínimo" RADIOMENU oTipo SIZE 65,08 PIXEL OF oFld:aDialogs[1]
  @ 025,265 RADIOITEM "Estoque Negativo" RADIOMENU oTipo SIZE 65,08 PIXEL OF oFld:aDialogs[1]
  @ 034,265 RADIOITEM "Estoque Positivo" RADIOMENU oTipo SIZE 65,08 PIXEL OF oFld:aDialogs[1]
 
 ACTIVATE DIALOG oDlg CENTER
 
RETURN NIL


Code (fw): Select all Collapse
function Troca()
?"with folder passes twice" + CRLF + "with dialog passes once"
RETURN


thank you
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: problems with radio and radioitem
Posted: Tue Jul 14, 2015 10:26 PM
Aferra,

I think what you are seeing is that you are changing focus from the folder to the message, then back to the folder. So, it appears to be getting called twice.

I tried the test code below and changed the Troca() function to write to a log file (test.log) each time it is called. It only logs one time.

Also I am not seeing any slowdown--it is very fast.

James

Code (fw): Select all Collapse
/*
Purpose  : Test calling of function by radion buttons
Author   : Aferra, Modified by James Bott
Date     : 7/14/2015 3:06:11 PM
Language : Fivewin/xHarbour
Updated  : 
Notes    :

*/

#include "fivewin.ch"

Function Main()

   LOCAL oDlg, oFld, nTipo:=1, oTipo

   DEFINE DIALOG oDlg FROM 0,0 TO 520,820 PIXEL
 
   @ 90,03 FOLDER oFld OF oDlg PROMPT "&Produto","&Movimentação","&Valores" ;
    PIXEL SIZE 405,208
 
   @ 000,195 GROUP TO 045,335 LABEL "Tipo do Relatório" PIXEL TRANSPARENT OF oFld:aDialogs[1]
   @ 007,195 RADIO oTipo VAR nTipo PROMPT "Tabela de Preço", "Tabela de Promoção", "Lista de Compra", "Lista de Compra Ideal" SIZE 65,9 PIXEL ON CHANGE Troca() OF oFld:aDialogs[1]
   @ 007,265 RADIOITEM "Sugestão de Compra" RADIOMENU oTipo SIZE 65,08 PIXEL OF oFld:aDialogs[1]
   @ 016,265 RADIOITEM "Estoque Mínimo" RADIOMENU oTipo SIZE 65,08 PIXEL OF oFld:aDialogs[1]
   @ 025,265 RADIOITEM "Estoque Negativo" RADIOMENU oTipo SIZE 65,08 PIXEL OF oFld:aDialogs[1]
   @ 034,265 RADIOITEM "Estoque Positivo" RADIOMENU oTipo SIZE 65,08 PIXEL OF oFld:aDialogs[1]
 
 ACTIVATE DIALOG oDlg CENTER
 
RETURN NIL

function Troca()
   //?"with folder passes twice" + CRLF + "with dialog passes once"
   logfile("test.log",{"Troca()"})
RETURN
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 159
Joined: Wed Mar 28, 2007 01:19 PM
Re: problems with radio and radioitem
Posted: Wed Jul 15, 2015 01:25 AM
I confirm the problem
Code (fw): Select all Collapse
Function Main()
   LOCAL oDlg, oFld, nTipo:=1, oTipo

   DEFINE DIALOG oDlg FROM 0,0 TO 520,820 PIXEL
   @ 90,03 FOLDER oFld OF oDlg PROMPT "&Produto","&Movimentação","&Valores"   PIXEL SIZE 405,208
   @ 000,195 GROUP TO 045,335 LABEL "Tipo do Relatório" PIXEL TRANSPARENT OF oFld:aDialogs[1]
   @ 007,195 RADIO oTipo VAR nTipo PROMPT "Tabela de Preço", "Tabela de Promoção", "Lista de Compra", ;
                   "Lista de Compra Ideal"    SIZE 65,9 PIXEL ON CHANGE Troca(nTipo) OF oFld:aDialogs[1]
   @ 007,265 RADIOITEM "Sugestão de Compra" RADIOMENU oTipo SIZE 65,08 PIXEL OF oFld:aDialogs[1]
   @ 016,265 RADIOITEM "Estoque Mínimo" RADIOMENU oTipo SIZE 65,08 PIXEL OF oFld:aDialogs[1]
   @ 025,265 RADIOITEM "Estoque Negativo" RADIOMENU oTipo SIZE 65,08 PIXEL OF oFld:aDialogs[1]
   @ 034,265 RADIOITEM "Estoque Positivo" RADIOMENU oTipo SIZE 65,08 PIXEL OF oFld:aDialogs[1]
   ACTIVATE DIALOG oDlg CENTER
RETURN NIL

function Troca(nTipo)
   logfile("test.log",{str(nTipo)})
RETURN nil

3 line-down gives:
07/14/15 22:18:09: 2
07/14/15 22:18:09: 2
07/14/15 22:18:10: 3
07/14/15 22:18:10: 3
07/14/15 22:18:10: 4
07/14/15 22:18:10: 4
:-) Euclides
Posts: 375
Joined: Tue Feb 10, 2015 09:48 AM
Re: problems with radio and radioitem
Posted: Wed Jul 15, 2015 09:05 AM
I tried it too,
Here the stacks: the top one is without the folder, the bottom two are with the folder.

here TRadMenu:Refresh():
Code (fw): Select all Collapse
METHOD Refresh() CLASS TRadMenu

   local nOption := Eval( ::bSetGet )
   local nAt     := AScan( ::aItems, { | oRadio | If( oRadio != nil, oRadio:lIsChecked(), .f. ) } )

   DEFAULT nOption := 1

   if nAt != nOption .and. nAt <= Len( ::aItems ) .and. Len( ::aItems ) > 0
      if nAt != 0
         ::aItems[ nAt ]:SetCheck( .f. )
      endif
      if ::aItems[ nOption ] != nil
         ::aItems[ nOption ]:SetCheck( .t. )
      endif
      if ::bChange != nil
         Eval( ::bChange, Self )
      endif
   endif

return nil

looks like in the case with folder, the click is called before than lIsCheckd returns true so nAt is not the new nOption, :-) :-)
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: problems with radio and radioitem
Posted: Wed Jul 15, 2015 11:57 AM

Euclides,

I just tested your example with FWH 15.05 and I get this in the test.log:

07/15/15 13:55:39: 2
07/15/15 13:55:42: 3
07/15/15 13:55:48: 4

Antonino,

Are you testing Euclides example ?

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 88
Joined: Wed Apr 28, 2010 06:34 PM
Re: problems with radio and radioitem
Posted: Wed Jul 15, 2015 12:05 PM

I thank all the answers.

Antonio, You suggest that update refresh the radio?

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: problems with radio and radioitem
Posted: Wed Jul 15, 2015 12:10 PM

I simply tested Euclides example and it worked fine with FWH 15.05

Is there any other example that you would like me to test ?

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 88
Joined: Wed Apr 28, 2010 06:34 PM
Re: problems with radio and radioitem
Posted: Wed Jul 15, 2015 12:37 PM

well, I moved the test to logfile () and believe me, this passing only once, now put this structure gives the error.

example

aArray: = {}

while eof ()
    AADD (aArray ....)
    skip
ENDDO

if I comment this line aArray: = {} my array doubles the data, I am confused now. :)

Posts: 88
Joined: Wed Apr 28, 2010 06:34 PM
Re: problems with radio and radioitem
Posted: Wed Jul 15, 2015 12:47 PM

I found the problem.

after while ... ENDDO have a msgyesno (), taking this msg () does not happen the problem, the logfiile shows only once passing within the function.

what to do?

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: problems with radio and radioitem
Posted: Wed Jul 15, 2015 04:51 PM

Before calling:

msgyesno()

Try this:

oDlg:Disable()

and after the msgyesno():

oDlg:Enable()

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 88
Joined: Wed Apr 28, 2010 06:34 PM
Re: problems with radio and radioitem
Posted: Wed Jul 15, 2015 06:07 PM

YES,

It worked perfectly, was already thinking about changing the screen to get the result, but now everything in order and with a simple solution ...

thank you Antonio

Continue the discussion