当前位置: 代码迷 >> Brew >> 怎么更改widget状态
  详细解决方案

怎么更改widget状态

热度:5463   发布时间:2013-02-26 00:00:00.0
如何更改widget状态?
我不知道brew里面有没有“活动”这个词,我想实现当widget A接收到方向键时,使widget B处于活动状态,这时再按方向键,就由B来处理。 我试了
  IWidget_MoveFocus(A, B );
  IWIDGET_SetSelected(B,false);
  IWIDGET_SetSelected(A,true);
  IWidget_SetFocus(B,false);
  IWidget_SetFocus(A,true);
这几个函数都不行,虽然焦点移动到了B,但按键事件还是被A接收到了,除非用点击一下B,B才能接收到事件,请问要做哪些设置才能让B能按收到事件。请大家帮忙.

注:我的A在一个container_a内,而container_a和B又都是container_main的孩子,我试了把焦点从container_a从移出来,还是不行。



------解决方案--------------------------------------------------------
发送一个avk_?啊
------解决方案--------------------------------------------------------
是不是应该使用 IWidget_MoveFocus(pw, B ); pw是根容器或者container_main对应的widget,不应该用A。

------解决方案--------------------------------------------------------
可能是你重载了A或者是B的事件了,
typedef struct _test{
AEEApplet a ;
AEEDeviceInfo DeviceInfo; 

IShell *meIshell;//
IDisplay *meIDisplay;
IRootForm *rootForm;
IForm *mainForm;

IXYContainer *mainContainer;

IWidget *text1Widget;
IWidget *text2Widget;
IXYContainer *aContaienr;
} test;


void testFouce(gridWidget1202 *pMe)
{
int result = 0;
WidgetPos wp;
WExtent tsWE;
IWidget *testWidget=NULL;
ISHELL_CreateInstance(pMe->meIshell,AEECLSID_ROOTFORM,(void**)&pMe->rootForm);
result = ISHELL_CreateInstance(pMe->meIshell, AEECLSID_FORM, (void **)&(pMe->mainForm));
result += ISHELL_CreateInstance(pMe->meIshell, AEECLSID_XYCONTAINER, (void **)&pMe->mainContainer);
result += ISHELL_CreateInstance(pMe->meIshell, AEECLSID_XYCONTAINER, (void **)&pMe->aContaienr);
result += ISHELL_CreateInstance(pMe->meIshell,AEECLSID_TEXTWIDGET,(void**)&pMe->text1Widget);
result += ISHELL_CreateInstance(pMe->meIshell,AEECLSID_TEXTWIDGET,(void**)&pMe->text2Widget);


tsWE.height=30;
tsWE.width=150;
IWIDGET_SetExtent(pMe->text1Widget,&tsWE);
wp.x=10;
wp.y=10;
wp.bVisible=TRUE;
result = IXYCONTAINER_Insert(pMe->aContaienr,pMe->text1Widget, WIDGET_ZNORMAL, &wp);

result = IXYCONTAINER_QueryInterface(pMe->aContaienr, AEEIID_WIDGET, (void**)&testWidget);
tsWE.height=150;
tsWE.width=240;
IWIDGET_SetExtent(testWidget,&tsWE);
wp.x=0;
wp.y=0;
wp.bVisible=TRUE;
result = IXYCONTAINER_Insert(pMe->mainContainer,testWidget, WIDGET_ZNORMAL, &wp);

tsWE.height=30;
tsWE.width=180;
IWIDGET_SetExtent(pMe->text2Widget,&tsWE);
wp.x=10;
wp.y=200;
wp.bVisible=TRUE;
result = IXYCONTAINER_Insert(pMe->mainContainer, pMe->text2Widget, WIDGET_ZNORMAL, &wp);

result = IXYCONTAINER_QueryInterface(pMe->mainContainer, AEEIID_WIDGET, (void**)&pMe->m_pWidget);
result += IFORM_SetWidget(pMe->mainForm, WID_FORM, pMe->m_pWidget);
IROOTFORM_PushForm(pMe->rootForm,pMe->mainForm);
}


 case EVT_APP_START:testFouce(pMe);return(TRUE);

case EVT_KEY:



if(wParam == AVK_UP)
{
IFORM_GetWidget(pMe->mainForm, WID_FORM, (IWidget **)&pWidget);
IWIDGET_MoveFocus(pWidget, (IWidget *)WIDGET_FOCUS_NEXT);
IWIDGET_Release(pWidget);
}

if(wParam == AVK_DOWN)
{
IFORM_GetWidget(pMe->mainForm, WID_FORM, (IWidget **)&pWidget);
IWIDGET_MoveFocus(pWidget, (IWidget *)WIDGET_FOCUS_PREV);
IWIDGET_Release(pWidget);
}
return(TRUE);
  相关解决方案