示例#1
0
bool CFFL_CheckBox::OnChar(CPDFSDK_Annot* pAnnot,
                           uint32_t nChar,
                           uint32_t nFlags) {
  switch (nChar) {
    case FWL_VKEY_Return:
    case FWL_VKEY_Space: {
      CPDFSDK_PageView* pPageView = pAnnot->GetPageView();
      ASSERT(pPageView);

      CPDFSDK_Annot::ObservedPtr pObserved(m_pWidget.Get());
      if (m_pFormFillEnv->GetInteractiveFormFiller()->OnButtonUp(
              &pObserved, pPageView, nFlags)) {
        if (!pObserved)
          m_pWidget = nullptr;
        return true;
      }
      if (!pObserved) {
        m_pWidget = nullptr;
        return true;
      }

      CFFL_FormFiller::OnChar(pAnnot, nChar, nFlags);

      CPWL_CheckBox* pWnd = GetCheckBox(pPageView, true);
      if (pWnd) {
        CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot);
        pWnd->SetCheck(!pWidget->IsChecked());
      }

      return CommitData(pPageView, nFlags);
    }
    default:
      return CFFL_FormFiller::OnChar(pAnnot, nChar, nFlags);
  }
}
示例#2
0
bool CFFL_CheckBox::OnLButtonUp(CPDFSDK_PageView* pPageView,
                                CPDFSDK_Annot* pAnnot,
                                uint32_t nFlags,
                                const CFX_PointF& point) {
  CFFL_Button::OnLButtonUp(pPageView, pAnnot, nFlags, point);

  if (!IsValid())
    return true;

  CPWL_CheckBox* pWnd = GetCheckBox(pPageView, true);
  if (pWnd) {
    CPDFSDK_Widget* pWidget = ToCPDFSDKWidget(pAnnot);
    pWnd->SetCheck(!pWidget->IsChecked());
  }

  return CommitData(pPageView, nFlags);
}