setFocusCallback method

void setFocusCallback(
  1. void focusIn()?,
  2. void focusOut()?
)

(en) Sets callbacks for when focus is gained and lost. Invalid if manager class is not set.

(ja) フォーカスがあたった時と外れた時のコールバックを設定します。 マネージャークラスが未設定の場合は無効です。

  • focusIn : The callback for focus in.
  • focusOut : The callback for focus out.

Implementation

void setFocusCallback(void Function()? focusIn, void Function()? focusOut) {
  final String? sid = getSID();
  if (sid == null || tfParams.p.manager == null) {
    return;
  } else {
    if (focusIn == null && focusOut == null) {
      getFocusNode()!.dispose();
      tfParams.p.manager!.getALLFocus()[sid] = FocusNode();
    } else {
      if (focusIn == null || focusOut == null) {
        getFocusNode()!.dispose();
        tfParams.p.manager!.getALLFocus()[sid] = FocusNode();
      }
      final FocusNode node = getFocusNode()!;
      node.addListener(() {
        if (node.hasFocus) {
          if (focusIn != null) {
            focusIn();
          }
        } else {
          if (focusOut != null) {
            focusOut();
          }
        }
      });
    }
  }
}