How to enable touch support for FORM? | developer.brewmp.com How to enable touch support for FORM? | developer.brewmp.com

Developer

How to enable touch support for FORM?

hi ,

I have created a "Root Form" with multiple Forms inside that. But in the handling I'm not getting touch events to handle. can anyone help me how to enable touch for Forms?(I enabled touch for widgets inside the form).

 

Thanks in Advance 

Hi,
You can enable touch in a form by using IRootForm_HandleEvent() and passing EVT_WDG_ENABLETOUCH, such as the following:
IRootForm_HandleEvent(piRootForm,  EVT_WDG_ENABLETOUCH, 0, 1);
 
-Jason

Hi,
You can enable touch in a form by using IRootForm_HandleEvent() and passing EVT_WDG_ENABLETOUCH, such as the following:
IRootForm_HandleEvent(piRootForm,  EVT_WDG_ENABLETOUCH, 0, 1);
 
-Jason

thanks for your help. 
I created an app which consists a button, placed it into a XYContainer and i added a listener to that button. finally i placed it into a form. i did as u said above, now touch is working but when i clicked the button control is not coming to "button listener function"(listener initialization is working proper). Any help?  

thanks for your help. 
I created an app which consists a button, placed it into a XYContainer and i added a listener to that button. finally i placed it into a form. i did as u said above, now touch is working but when i clicked the button control is not coming to "button listener function"(listener initialization is working proper). Any help?  

Not sure what is wrong with your code, try debugging. I tried the below code and it worked.
static int c_formsapp_CreateForm(c_formsapp *me)
{
int nErr = 0;

// create the root form
nErr = ISHELL_CreateInstance(me->piShell, AEECLSID_ROOTFORM, (void **)&me->piRootForm);

// create the simple form
if(SUCCESS == nErr) {
nErr = c_formsapp_CreateSimpleForm(me);
}

if (SUCCESS == nErr) {
(void) IROOTFORM_HandleEvent(me->piRootForm, EVT_WDG_ENABLETOUCH, 0, 1);
}

// if there have been no failures up to this point then return success
return nErr;

// Model Listener for Button widget
static void c_formsapp_ButtonListener(c_formsapp *me, ModelEvent *pEvent)
{
if (EVT_MDL_WIDGETELEM_CLICK == pEvent->evCode)
{
//I am here
}

// Create the form
int c_formsapp_CreateSimpleForm(c_formsapp *me)
{
WidgetExtent weCont;
int nX, nY, dX, dY;
int nErr = SUCCESS;
IWidget *piw = NULL;

nX=nY=0;
dX=dY=3;

// --- FORM
// create the form
nErr = ISHELL_CreateInstance(me->piShell, AEECLSID_FORM, (void **)&me->piForm);
if(SUCCESS == nErr) {
// set some keys and titles
(void)IFORM_SetText(me->piForm, FID_TITLE, L"Test Form");
(void)IFORM_SetText(me->piForm, FID_SOFTKEY1, L"Test1");
(void)IFORM_SetText(me->piForm, FID_SOFTKEY2, L"Test2");
}

// --- XY CONTAINER
if(SUCCESS == nErr) {
nErr = ISHELL_CreateInstance(me->piShell, AEECLSID_XYCONTAINER, (void**)&me->picXY);
}
// query for the widget interface
if(SUCCESS == nErr) {
nErr = IXYCONTAINER_QueryInterface(me->picXY, AEEIID_WIDGET, (void**)&piw);
}
if(SUCCESS == nErr) {
nErr = IFORM_SetWidget(me->piForm, WID_FORM, piw);
}
// set some colors etc on the container widget
if(SUCCESS == nErr) {
(void)IWIDGET_SetBGColor(piw, MAKE_RGBA(0,0,128,255));
(void)IWIDGET_SetBorderColor(piw, MAKE_RGBA(255,255,255,255));
(void)IWIDGET_SetBorderWidth(piw, 1);
(void)IWIDGET_SetFGColor(piw, MAKE_RGBA(255,255,0,255));
IWIDGET_GetPreferredExtent(piw, &weCont);
}
RELEASEIF(piw);

// --- BUTTON WIDGET
if(SUCCESS == nErr) {
nErr = ISHELL_CreateInstance(me->piShell, AEECLSID_BUTTONWIDGET, (void**)&me->piwButton);
}
if(SUCCESS == nErr) {
IWidget *piwButton = me->piwButton;
IWidget *pchild = NULL;
nErr = ISHELL_CreateInstance(me->piShell, AEECLSID_STATICWIDGET, (void**)&pchild);
if(NULL != pchild)
{
(void)IWIDGET_SetText(pchild, L"Button", FALSE);
(void)IWIDGET_SetBorderWidth(pchild, 0);
(void)IWIDGET_SetFontClass(pchild, AEECLSID_FONTSYSBOLD);
(void)IWIDGET_SetFlags(pchild, IDF_ALIGN_CENTER|IDF_ALIGN_MIDDLE);

IDECORATOR_SetWidget(CAST(IDecorator *, piwButton), pchild);
}
RELEASEIF(pchild);

// add a listener for button
{
IModel *pivmOK = 0;
(void)IWIDGET_GetViewModel(piwButton, &pivmOK);
(void)IMODEL_AddListenerEx(pivmOK, &me->mlButton, (PFNLISTENER)c_formsapp_ButtonListener, me);
RELEASEIF(pivmOK);
}

// insert
{
WidgetPos wpos;
WidgetExtent wex;
IWIDGET_GetPreferredExtent(piwButton, &wex);
IWIDGET_SetExtent(piwButton, &wex);
wpos.x = nX;
wpos.y = nY;
wpos.bVisible = TRUE;
(void)IXYCONTAINER_Insert(me->picXY, piwButton, NULL, &wpos);
}
}

// push the form to the root form
nErr = IROOTFORM_PushForm(me->piRootForm, me->piForm);

return nErr;

Not sure what is wrong with your code, try debugging. I tried the below code and it worked.
static int c_formsapp_CreateForm(c_formsapp *me)
{
int nErr = 0;

// create the root form
nErr = ISHELL_CreateInstance(me->piShell, AEECLSID_ROOTFORM, (void **)&me->piRootForm);

// create the simple form
if(SUCCESS == nErr) {
nErr = c_formsapp_CreateSimpleForm(me);
}

if (SUCCESS == nErr) {
(void) IROOTFORM_HandleEvent(me->piRootForm, EVT_WDG_ENABLETOUCH, 0, 1);
}

// if there have been no failures up to this point then return success
return nErr;

// Model Listener for Button widget
static void c_formsapp_ButtonListener(c_formsapp *me, ModelEvent *pEvent)
{
if (EVT_MDL_WIDGETELEM_CLICK == pEvent->evCode)
{
//I am here
}

// Create the form
int c_formsapp_CreateSimpleForm(c_formsapp *me)
{
WidgetExtent weCont;
int nX, nY, dX, dY;
int nErr = SUCCESS;
IWidget *piw = NULL;

nX=nY=0;
dX=dY=3;

// --- FORM
// create the form
nErr = ISHELL_CreateInstance(me->piShell, AEECLSID_FORM, (void **)&me->piForm);
if(SUCCESS == nErr) {
// set some keys and titles
(void)IFORM_SetText(me->piForm, FID_TITLE, L"Test Form");
(void)IFORM_SetText(me->piForm, FID_SOFTKEY1, L"Test1");
(void)IFORM_SetText(me->piForm, FID_SOFTKEY2, L"Test2");
}

// --- XY CONTAINER
if(SUCCESS == nErr) {
nErr = ISHELL_CreateInstance(me->piShell, AEECLSID_XYCONTAINER, (void**)&me->picXY);
}
// query for the widget interface
if(SUCCESS == nErr) {
nErr = IXYCONTAINER_QueryInterface(me->picXY, AEEIID_WIDGET, (void**)&piw);
}
if(SUCCESS == nErr) {
nErr = IFORM_SetWidget(me->piForm, WID_FORM, piw);
}
// set some colors etc on the container widget
if(SUCCESS == nErr) {
(void)IWIDGET_SetBGColor(piw, MAKE_RGBA(0,0,128,255));
(void)IWIDGET_SetBorderColor(piw, MAKE_RGBA(255,255,255,255));
(void)IWIDGET_SetBorderWidth(piw, 1);
(void)IWIDGET_SetFGColor(piw, MAKE_RGBA(255,255,0,255));
IWIDGET_GetPreferredExtent(piw, &weCont);
}
RELEASEIF(piw);

// --- BUTTON WIDGET
if(SUCCESS == nErr) {
nErr = ISHELL_CreateInstance(me->piShell, AEECLSID_BUTTONWIDGET, (void**)&me->piwButton);
}
if(SUCCESS == nErr) {
IWidget *piwButton = me->piwButton;
IWidget *pchild = NULL;
nErr = ISHELL_CreateInstance(me->piShell, AEECLSID_STATICWIDGET, (void**)&pchild);
if(NULL != pchild)
{
(void)IWIDGET_SetText(pchild, L"Button", FALSE);
(void)IWIDGET_SetBorderWidth(pchild, 0);
(void)IWIDGET_SetFontClass(pchild, AEECLSID_FONTSYSBOLD);
(void)IWIDGET_SetFlags(pchild, IDF_ALIGN_CENTER|IDF_ALIGN_MIDDLE);

IDECORATOR_SetWidget(CAST(IDecorator *, piwButton), pchild);
}
RELEASEIF(pchild);

// add a listener for button
{
IModel *pivmOK = 0;
(void)IWIDGET_GetViewModel(piwButton, &pivmOK);
(void)IMODEL_AddListenerEx(pivmOK, &me->mlButton, (PFNLISTENER)c_formsapp_ButtonListener, me);
RELEASEIF(pivmOK);
}

// insert
{
WidgetPos wpos;
WidgetExtent wex;
IWIDGET_GetPreferredExtent(piwButton, &wex);
IWIDGET_SetExtent(piwButton, &wex);
wpos.x = nX;
wpos.y = nY;
wpos.bVisible = TRUE;
(void)IXYCONTAINER_Insert(me->picXY, piwButton, NULL, &wpos);
}
}

// push the form to the root form
nErr = IROOTFORM_PushForm(me->piRootForm, me->piForm);

return nErr;

I tried with your code(as mentioned above) in that if you click on button widget its listener function is not invoking. In my app also same problem. how to solve this?

I tried with your code(as mentioned above) in that if you click on button widget its listener function is not invoking. In my app also same problem. how to solve this?

It worked for me; clicking on button widget iinvoked listener function. BTW, I used Candybar 1.0.3.692 simulator.

It worked for me; clicking on button widget iinvoked listener function. BTW, I used Candybar 1.0.3.692 simulator.

I am also using the same simulator but its not working. 

I am also using the same simulator but its not working.