problems with radio and radioitem

problems with radio and radioitem

Postby aferra » Tue Jul 14, 2015 3: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: Select all  Expand view

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: Select all  Expand view

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: Select all  Expand view

function Troca()
?"with folder passes twice" + CRLF + "with dialog passes once"
RETURN
 


thank you
aferra
 
Posts: 88
Joined: Wed Apr 28, 2010 6:34 pm

Re: problems with radio and radioitem

Postby James Bott » 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: Select all  Expand view
/*
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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: problems with radio and radioitem

Postby Euclides » Wed Jul 15, 2015 1:25 am

I confirm the problem
Code: Select all  Expand view

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
:cry: Euclides
User avatar
Euclides
 
Posts: 154
Joined: Wed Mar 28, 2007 1:19 pm

Re: problems with radio and radioitem

Postby AntoninoP » Wed Jul 15, 2015 9:05 am

I tried it too,
Here the stacks: the top one is without the folder, the bottom two are with the folder.
Image
here TRadMenu:Refresh():
Code: Select all  Expand view
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, :?: :?:
AntoninoP
 
Posts: 375
Joined: Tue Feb 10, 2015 9:48 am
Location: Albenga, Italy

Re: problems with radio and radioitem

Postby Antonio Linares » 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
User avatar
Antonio Linares
Site Admin
 
Posts: 41329
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: problems with radio and radioitem

Postby aferra » Wed Jul 15, 2015 12:05 pm

I thank all the answers.

Antonio, You suggest that update refresh the radio?
aferra
 
Posts: 88
Joined: Wed Apr 28, 2010 6:34 pm

Re: problems with radio and radioitem

Postby Antonio Linares » 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
User avatar
Antonio Linares
Site Admin
 
Posts: 41329
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: problems with radio and radioitem

Postby aferra » 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. :)
aferra
 
Posts: 88
Joined: Wed Apr 28, 2010 6:34 pm

Re: problems with radio and radioitem

Postby aferra » 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?
aferra
 
Posts: 88
Joined: Wed Apr 28, 2010 6:34 pm

Re: problems with radio and radioitem

Postby Antonio Linares » Wed Jul 15, 2015 4:51 pm

Before calling:

msgyesno()

Try this:

oDlg:Disable()

and after the msgyesno():

oDlg:Enable()
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41329
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: problems with radio and radioitem

Postby aferra » Wed Jul 15, 2015 6: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
aferra
 
Posts: 88
Joined: Wed Apr 28, 2010 6:34 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 27 guests