Callback function of a field-dbe-element shall not only fire at enter-click

Hello dxl-developers,

 

as dxl help docu, if you define a callback function for a field-element, it will only be fired

when the user clicks RETURN or ENTER with the Cursor in the field.

 

I would need a callback function for a field element, which will be fired if I write a string

into it by the dxl-function set(...).

 

Does anyone have an idea how can I achieve this?

 


MarcoLuk - Wed Oct 04 11:16:18 EDT 2017

Re: Callback function of a field-dbe-element shall not only fire at enter-click
7XUT_Antonio_Norkus - Thu Oct 05 13:37:10 EDT 2017

Have you tried calling the callback function after you have called set(..)?

Re: Callback function of a field-dbe-element shall not only fire at enter-click
MarcoLuk - Fri Oct 06 03:25:41 EDT 2017

7XUT_Antonio_Norkus - Thu Oct 05 13:37:10 EDT 2017

Have you tried calling the callback function after you have called set(..)?

Thanks for your advice. I also thougt the same.

Meanwhile I used a complex delegate mechanism to invoke a delegate function.

Delegate mechanism sources:https://www.ibm.com/developerworks/community/forums/html/threadTopic?id=6b3a0982-5c2d-4d2d-a338-dbb760616e3c

Re: Callback function of a field-dbe-element shall not only fire at enter-click
O.Wilkop - Mon Oct 09 04:35:53 EDT 2017

MarcoLuk - Fri Oct 06 03:25:41 EDT 2017

Thanks for your advice. I also thougt the same.

Meanwhile I used a complex delegate mechanism to invoke a delegate function.

Delegate mechanism sources:https://www.ibm.com/developerworks/community/forums/html/threadTopic?id=6b3a0982-5c2d-4d2d-a338-dbb760616e3c

While not exactly what you want, check the following example:

DB dbMain
DBE dbeTimer
DBE dbeFieldInput
DBE dbeFieldOutput

void timerCallback(DBE x){
        string value = get(dbeFieldInput);
        set(dbeFieldOutput, value);
}

dbMain = centered("Timer example");
dbeTimer = timer(dbMain, 0.1, timerCallback, ""); //calls timerCallback every 0.1 seconds
label(dbMain, ""); //spacer
dbeFieldInput = field(dbMain, "Input", "", 40);
dbeFieldOutput = field(dbMain, "Output", "", 40, true);


show dbMain;

 

Depending on what exactly you want to do you might have to add some state-keeping (in case you only want something to happen when the value has actually changed), but this is one way to do it.

 

There is also "bool stopTimer(DBE)" and "bool startTimer(DBE)" functions in case you want to stop the timers at some point.

Re: Callback function of a field-dbe-element shall not only fire at enter-click
MarcoLuk - Mon Oct 09 04:41:46 EDT 2017

O.Wilkop - Mon Oct 09 04:35:53 EDT 2017

While not exactly what you want, check the following example:

DB dbMain
DBE dbeTimer
DBE dbeFieldInput
DBE dbeFieldOutput

void timerCallback(DBE x){
        string value = get(dbeFieldInput);
        set(dbeFieldOutput, value);
}

dbMain = centered("Timer example");
dbeTimer = timer(dbMain, 0.1, timerCallback, ""); //calls timerCallback every 0.1 seconds
label(dbMain, ""); //spacer
dbeFieldInput = field(dbMain, "Input", "", 40);
dbeFieldOutput = field(dbMain, "Output", "", 40, true);


show dbMain;

 

Depending on what exactly you want to do you might have to add some state-keeping (in case you only want something to happen when the value has actually changed), but this is one way to do it.

 

There is also "bool stopTimer(DBE)" and "bool startTimer(DBE)" functions in case you want to stop the timers at some point.

Thank you very much. This is also an interesting solution.

I will try this at another application.