ucos中edit的WM_NOTIFY_CHILD_HAS_FOCUS问题

我在界面中使用了,两个edit,当点击edit的时候,清空里面的显示,问题是WM_NOTIFY_CHILD_HAS_FOCUS在交替点击的时候,会每个都响应一次,导致交替的时候,把之前点击的内容也清空,这个在下面三个内容中,得到解答

static void _OnTouch(EDIT_Handle hObj, EDIT_Obj* pObj, WM_MESSAGE*pMsg) {
  GUI_TOUCH_tState* pState = (GUI_TOUCH_tState*)pMsg->Data.p;
  if (pMsg->Data.p) {  /* Something happened in our area (pressed or released) */
    if (pState->Pressed) {
      GUI_DEBUG_LOG1("EDIT__Callback(WM_TOUCH, Pressed, Handle %d)\n",1);
      _SetCursor(hObj, pObj, pState->x);
   WM_SetFocus(hObj);
    } else {
      GUI_DEBUG_LOG1("EDIT__Callback(WM_TOUCH, Released, Handle %d)\n",1);
    }
  } else {
    GUI_DEBUG_LOG1("_EDIT_Callback(WM_TOUCH, Moved out, Handle %d)\n",1);
  }
}

int WM_SetFocus(WM_HWIN hWin) {
  int r;
  WM_MESSAGE Msg;
  WM_LOCK();
  if ((hWin) && (hWin != WM__hWinFocus)) {
    Msg.MsgId  = WM_SET_FOCUS;
    /* Send a "no more foucs" message to window losing focus */
    Msg.Data.v = 0;
    WM_SendMessage(WM__hWinFocus, &Msg);
    /* Send "You have the focus now" message to the window */
    Msg.Data.v = 1;
    WM_SendMessage(WM__hWinFocus = hWin, &Msg);
    r = Msg.Data.v;
  } else {
    r = 1;
  }
  WM_UNLOCK();
  return r;
}

int WIDGET_HandleActive(WM_HWIN hObj, WM_MESSAGE* pMsg) {
  WM_MESSAGE Msg;
  WIDGET* pWidget = WIDGET_H2P(hObj);
  switch (pMsg->MsgId) {
    case WM_GET_ID:
      pMsg->Data.v = pWidget->Id;
      return 0;                        /* Message handled -> Return */
    case WM_SET_FOCUS:
      if (pMsg->Data.v == 1) {
        WIDGET_SetState(hObj, pWidget->State |  WIDGET_STATE_FOCUS);    //   ( 1 )
      } else {
        WIDGET_SetState(hObj, pWidget->State & ~WIDGET_STATE_FOCUS);
      }
        Msg.MsgId = WM_NOTIFY_CHILD_HAS_FOCUS;           // ( 2 )
     Msg.Data.v = pMsg->Data.v;
      WM_SendToParent(hObj, &Msg);
      return 0;
    case WM_GET_HAS_FOCUS:

。。。。

}

将2,放到1的后面就可以了。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值