Virtual Keyboard listener problem | developer.brewmp.com Virtual Keyboard listener problem | developer.brewmp.com

Developer

Virtual Keyboard listener problem

Forums:

Hi guys, 

 

I have a problem with virtual keyboard, when I am exiting from my app i have to check if is my VK opened, and close it if is, a then close app.

I figure out that i can do that only by adding the listener on the status model of the virtual keyboard --- IController_GetVirtualInputStatusModel(virtualManager, &virtualKeyboardModel); , than I registered listener for the model, to recieve all events tied to virtual input status model. That way I am able to track the status of the virtual keyboard, but it doesn't work, listener function doesn't recieve any event, no matter what I do :/ :/

Here is my code, so please  take a look, maybe I did something wrong :)

 

 

bmpp::RootContainer::VirtualKeyboardListener::VirtualKeyboardListener( IController* virtualManager )

{

IModel* virtualKeyboardModel = NULL;

 

AEEResult nResult = IController_GetVirtualInputStatusModel(virtualManager, &virtualKeyboardModel);

if (nResult != SUCCESS) { dbg_assert(false); return; }

 

construct(virtualKeyboardModel);

 

SAFE_RELEASE(virtualKeyboardModel, IModel_Release);

}

 

void bmpp::RootContainer::VirtualKeyboardListener::construct( IModel* pModel )

{

MEMSET(&m_Listener, 0, sizeof(m_Listener));

 

LISTENER_Init(&m_Listener, VirtualKeyboardListener::HandleEvent, (void*)this);

m_Listener.pfnCancel = NULL;

m_Listener.pCancelData = NULL;

m_Listener.pNext = NULL;

m_Listener.pPrev = NULL;

(void)IModel_AddListener(pModel, &m_Listener);

}

 

bmpp::RootContainer::VirtualKeyboardListener::~VirtualKeyboardListener( void )

{

if (NULL != m_Listener.pfnListener)

{

LISTENER_Cancel(&m_Listener);

}

}

 

void bmpp::RootContainer::VirtualKeyboardListener::HandleEvent( void* pUserData, ModelEvent* pEvent )

{

(static_cast(pUserData))->handleEvent(pEvent);

}

 

void bmpp::RootContainer::VirtualKeyboardListener::handleEvent( ModelEvent* pEvent )

{

 

 

if(pEvent->evCode == EVT_MDL_VIRTUALINPUT_STATUS_CHANGE)

{

VirtualInputStatusEvent* vise = (VirtualInputStatusEvent*) (pEvent);

 

if(vise->nStatus == VIRTUALINPUT_STATUS_OPEN)

isVKOpened = TRUE;

else if(vise->nStatus == VIRTUALINPUT_STATUS_CANCEL)

isVKOpened = FALSE;

else if(vise->nStatus == VIRTUALINPUT_STATUS_ACCEPT)

isVKOpened = FALSE;

 

}

}

 

 

 

tnx;)

Please "Insert code using syntaxhighligher" button to make ti readable.
I tried below code snippet on simulator and it worked:
IWidget_EnableVirtualInput(pMe->piwRoot); //enable virtual input on root container
nErr = IWidget_GetVirtualInputMgr(pMe->piwRoot, &pMe->picVirtualInputMgr);
nErr = IController_GetVirtualInputStatusModel(pMe->picVirtualInputMgr, &pMe->pmVKstatusModel);

LISTENER_Init(&pMe->mlStatus, VirtualInputStatusCB, pMe);
nErr = IModel_AddListener(pMe->pmVKstatusModel, &pMe->mlStatus);

//callback method
void VirtualInputStatusCB(void *pUserData, ModelEvent*pEvent)
{
c_widgetsamplevirtualinput_app *pMe = (c_widgetsamplevirtualinput_app*)pUserData;
VirtualInputStatusEvent *pVISModel = (VirtualInputStatusEvent *)pEvent;
DBGPRINTF("VirtualInputStatusCB");

if(pVISModel->nStatus == VIRTUALINPUT_STATUS_OPEN)
DBGPRINTF("VIRTUALINPUT_STATUS_OPEN");
else if(pVISModel->nStatus == VIRTUALINPUT_STATUS_ACCEPT)
{
int ret;
AECHAR *pszText = MALLOC(100);
DBGPRINTF("VIRTUALINPUT_STATUS_ACCEPT");
ret = IWidget_GetTextWidgetText(pMe->pTextWgt, &pszText);
DBGPRINTF("%S", pszText);
}
else if(pVISModel->nStatus == VIRTUALINPUT_STATUS_CANCEL)
DBGPRINTF("VIRTUALINPUT_STATUS_CANCEL");
else if(pVISModel->nStatus == VIRTUALINPUT_STATUS_MOVE)
DBGPRINTF("VIRTUALINPUT_STATUS_MOVE");

 

Please "Insert code using syntaxhighligher" button to make ti readable.
I tried below code snippet on simulator and it worked:
IWidget_EnableVirtualInput(pMe->piwRoot); //enable virtual input on root container
nErr = IWidget_GetVirtualInputMgr(pMe->piwRoot, &pMe->picVirtualInputMgr);
nErr = IController_GetVirtualInputStatusModel(pMe->picVirtualInputMgr, &pMe->pmVKstatusModel);

LISTENER_Init(&pMe->mlStatus, VirtualInputStatusCB, pMe);
nErr = IModel_AddListener(pMe->pmVKstatusModel, &pMe->mlStatus);

//callback method
void VirtualInputStatusCB(void *pUserData, ModelEvent*pEvent)
{
c_widgetsamplevirtualinput_app *pMe = (c_widgetsamplevirtualinput_app*)pUserData;
VirtualInputStatusEvent *pVISModel = (VirtualInputStatusEvent *)pEvent;
DBGPRINTF("VirtualInputStatusCB");

if(pVISModel->nStatus == VIRTUALINPUT_STATUS_OPEN)
DBGPRINTF("VIRTUALINPUT_STATUS_OPEN");
else if(pVISModel->nStatus == VIRTUALINPUT_STATUS_ACCEPT)
{
int ret;
AECHAR *pszText = MALLOC(100);
DBGPRINTF("VIRTUALINPUT_STATUS_ACCEPT");
ret = IWidget_GetTextWidgetText(pMe->pTextWgt, &pszText);
DBGPRINTF("%S", pszText);
}
else if(pVISModel->nStatus == VIRTUALINPUT_STATUS_CANCEL)
DBGPRINTF("VIRTUALINPUT_STATUS_CANCEL");
else if(pVISModel->nStatus == VIRTUALINPUT_STATUS_MOVE)
DBGPRINTF("VIRTUALINPUT_STATUS_MOVE");