Ucgui324按鍵單擊響應

 
在gui的學習中,原本的響應過程是:第一次點擊,先取消之前按鍵的焦點等狀態,並在當前按鍵聚焦等,第二次點擊纔會動作當前按鍵,並重繪按鍵。
在函數:
/****************************************************************
*
*       WM_HandleHID      
*
* Polls the touch screen. If something has changed,
* sends a message to the concerned window.
*
* Return value:
*   0 if nothing has been done
*   1 if touch message has been sent
*/
int WM_HandleHID(void) {
  int r = 0;
  static GUI_TOUCH_tState StateLast;
  GUI_HID_STATE State;
  GUI_HID_GetState(&State);
  WM_LOCK();
  WM__pfDeleteWindowHook = _cbDeleteWindow;   /* TBD in the future... Hook function management in order to allow multiple hook functions */
  #if GUI_SUPPORT_CURSOR
    GUI_CURSOR_SetPosition(State.x, State.y);
  #endif
  if (StateLast.Pressed | State.Pressed) {
    if (   (StateLast.x != State.x)
        || (StateLast.y != State.y)
        || ((StateLast.Pressed ? 1:0) != (State.Pressed ? 1:0)))
    {
      WM_MESSAGE Msg;
      WM_HWIN hWin;
      StateLast = State;             /* Remember current values */
      r = 1;
      Msg.MsgId = WM_TOUCH;
      Msg.Data.p = (void*)&State;
      if (WM__hCapture == 0) {
        hWin = WM_Screen2hWin(State.x, State.y);
      } else {
        hWin = WM__hCapture;
      }
      // Tell window if it is no longer pressed
      /*if (_hWinLast != hWin) {
        if (_hWinLast != 0) {
          if (State.Pressed) {
            Msg.Data.p = NULL;    // no longer in this window
          } else {     // "Clicked" in this window
            StateLast.Pressed =0;
            Msg.Data.p = (void*)&StateLast;
          }
          GUI_DEBUG_LOG1 ("\nSending WM_Touch to LastWindow %d (out of area)", _hWinLast);
          WM_SendMessage(_hWinLast, &Msg);
          _hWinLast = 0;
         }
      }
      */
      if (hWin) {           /* Sending WM_Touch to Window */
        /* convert screen into window coordinates */
        WM_Obj* pWin = WM_H2P(hWin);
        State.x -= pWin->Rect.x0;
        State.y -= pWin->Rect.y0;
        WM_SendMessage(hWin, &Msg);
        /* Remember window */
        if (State.Pressed) {
      //    _hWinLast = hWin;
        } else {
          /* Handle automatic captue release */
          if (WM__CaptureReleaseAuto) {
            WM_ReleaseCapture();
          }
       //   _hWinLast = 0;
        }
      }
    }
  }
  WM_UNLOCK();
  return r;
}
註釋掉紅色部分,不把前一次的窗體和當前窗體比較,可以單擊動作。
修改button.c中的重繪函數,使其每次重繪都是3d顯示即可。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章