Page 1 of 1

DCPUSHBUTTONXP with array caption

Posted: Thu Sep 08, 2022 6:41 am
by Tom
DCPUSHBUTTONs support an array caption with two textes, which toggle if the buttons are enabled/disabled. DCPUSHBUTTONXPs should support this aswell, but they don't. Here is a sample with a workaround:

Code: Select all

#include 'dcdialog.ch'
#pragma library("dclipx.lib")

proc main
LOCAL GetList := {}, aBez1 := {"aktiv","inaktiv"}, i := 1

/*  * Wenn nicht auskommentiert  keine Caption */
oConfig := DC_XbpPushButtonXPConfig():new()
oConfig:radius := 20
oConfig:bgColor := GRA_CLR_CYAN

* Workaround:

@ 02,12 dcpushbuttonxp caption {||abez1[IF(i=1,1,2)]} size 10,1 ;
        action {||nil} when {||i=1} config oConfig

@ 02,23 dcpushbuttonxp caption {||abez1[IF(i=2,1,2)]} size 10,1 ;
        action {||nil} when {||i=2} config oConfig

* Legacy buttons:

@ 02,34 dcpushbutton caption abez1 size 10,1 ;
        action {||nil} when {||i=1}

@ 02,45 dcpushbutton caption abez1 size 10,1 ;
        action {||nil} when {||i=2}

* ButtonsXP without workaround:

@ 02,56 dcpushbuttonxp caption abez1 size 10,1 ;
        action {||nil} when {||i=1} config oConfig

@ 02,67 dcpushbuttonxp caption abez1 size 10,1 ;
        action {||nil} when {||i=2} config oConfig


@ 04,12 DCPUSHBUTTON CAPTION 'Toggle' SIZE 10,1 ACTION {||i++,IF(i>2,i:=1,NIL),DC_GetRefresh(GetList)}

DCREAD GUI fit ADDBUTTONS

RETURN

*------------------

proc appsys
return

Re: DCPUSHBUTTONXP with array caption

Posted: Thu Sep 08, 2022 7:18 am
by rdonnay
Thanks for that Tom.

I forgot that DCPUSHBUTTON even had that feature or I would have added it to DCPUSHBUTTONXP.

I'll plan to add it in next build.

Re: DCPUSHBUTTONXP with array caption

Posted: Thu Sep 08, 2022 8:02 am
by Tom
Thx!