Page 1 of 1

BUTTON via DCGETOPTIONS

Posted: Mon Jul 28, 2014 1:51 am
by Janko
I am widely using creation of push buttons via GETOPTIONS descriptions in aButtons.
But when it is needed to change caption of a button during run time there is a problem (for me) how to access it. Parameter 7 in aButtons array is obviously not a name of the object, so what would be the way to change the caption?

Thanks and regards
JAnko

Re: BUTTON via DCGETOPTIONS

Posted: Mon Jul 28, 2014 2:55 am
by Tom
Use a codeblock for the caption. Call DC_GetRefresh(GetList) when changing is needed.

Re: BUTTON via DCGETOPTIONS

Posted: Mon Jul 28, 2014 7:38 am
by Janko
Tom,
this is how button(s) is created. Caption is empty. If I read the manual for 'BUTTONS' option in DCGETOPTIONS, only 'C' is allowed as a caption definition.

Code: Select all

LOCAL  bBlock:={|| if(lFlt,' OFF ',' ON  ')}
LOCAL  aButtons:={ { (bBlock),90,,{|| (if(lFlt,lflt:=.f.,lFlt:=.t.), DC_GetRefresh(Getlist))} }  }

   DCGETOPTIONS   BUTTONS aButtons
   DCREAD GUI   TITLE "Izbor " ;
   FIT MODAL SETAPPWINDOW ;
   BUTTONS  DCGUI_BUTTON_OK    OPTIONS GetOptions    FIT TO lOk

Or I misunderstood your guidelines.

Thanks for your ansver

JAnko

Re: BUTTON via DCGETOPTIONS

Posted: Mon Jul 28, 2014 7:52 am
by rdonnay
LOCAL aButtons:={ { (bBlock),90,,{|| (if(lFlt,lflt:=.f.,lFlt:=.t.), DC_GetRefresh(Getlist))} } }
This is not correct.

Please explain how you want the button to behave and I will show you the code to do it.

Re: BUTTON via DCGETOPTIONS

Posted: Mon Jul 28, 2014 8:44 am
by Janko
Roger,

I want to change caption of button that is defined via DGGETOPTIONS during runtime. When lFlt:=.t. caption is 'ON' otherwise it is 'OFF'.

Code: Select all


aButtons:=  {  {'ON/OFF ',90,,{|| (if(lFlt,lflt:=.f.,lFlt:=.t.), DC_GetRefresh(Getlist))} } }    //   original button definition   

Thanks in advance

JAnko

Re: BUTTON via DCGETOPTIONS

Posted: Mon Jul 28, 2014 8:50 am
by rdonnay
Try this:

Code: Select all

aButtons :=  {  {||IIF(lFlt,'ON','OFF')},90,,{||lFlt := !lFlt, DC_GetRefresh(Getlist)} } }

Re: BUTTON via DCGETOPTIONS

Posted: Mon Jul 28, 2014 9:39 am
by Janko
Thanks, it Works like desired.

BR JAnko