Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Protected Attributes
nsTextEditorFocusListener Class Reference

editor Implementation of the FocusListener interface More...

#include <nsEditorEventListeners.h>

Inheritance diagram for nsTextEditorFocusListener:
Inheritance graph
[legend]
Collaboration diagram for nsTextEditorFocusListener:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 nsTextEditorFocusListener ()
 default constructor
virtual ~nsTextEditorFocusListener ()
 default destructor
void SetEditor (nsIEditor *aEditor)
 SetEditor gives an address to the editor that will be accessed.
NS_DECL_ISUPPORTS NS_IMETHOD HandleEvent (nsIDOMEvent *aEvent)
NS_IMETHOD Focus (nsIDOMEvent *aEvent)
 Processes a focus event.
NS_IMETHOD Blur (nsIDOMEvent *aEvent)
 Processes a blur event.
void handleEvent (in nsIDOMEvent event)
 This method is called whenever an event occurs of the type for which the EventListener interface was registered.

Protected Attributes

nsIEditormEditor

Detailed Description

editor Implementation of the FocusListener interface

Definition at line 244 of file nsEditorEventListeners.h.


Constructor & Destructor Documentation

default constructor

Definition at line 955 of file nsEditorEventListeners.cpp.

{
}

default destructor

Definition at line 959 of file nsEditorEventListeners.cpp.

{
}

Member Function Documentation

Processes a blur event.

Parameters:
aMouseEvent
See also:
nsIDOMEvent.h
Returns:
whether the event was consumed or ignored.
See also:
nsresult

Implements nsIDOMFocusListener.

Definition at line 1066 of file nsEditorEventListeners.cpp.

{
  NS_ENSURE_ARG(aEvent);
  // turn off selection and caret
  if (mEditor)
  {
    aEvent->StopPropagation();

    // when imeEditor exists, call ForceCompositionEnd() to tell
    // the input focus is leaving first
    nsCOMPtr<nsIEditorIMESupport> imeEditor = do_QueryInterface(mEditor);
    if (imeEditor) {
      imeEditor->ForceCompositionEnd();
      imeEditor->NotifyIMEOnBlur();
    }

    nsCOMPtr<nsIEditor>editor = do_QueryInterface(mEditor);
    if (editor)
    {
      nsCOMPtr<nsISelectionController>selCon;
      editor->GetSelectionController(getter_AddRefs(selCon));
      if (selCon)
      {
        selCon->SetCaretEnabled(PR_FALSE);

        PRUint32 flags;
        mEditor->GetFlags(&flags);
        if((flags & nsIPlaintextEditor::eEditorWidgetMask)  ||
          (flags & nsIPlaintextEditor::eEditorPasswordMask) ||
          (flags & nsIPlaintextEditor::eEditorReadonlyMask) ||
          (flags & nsIPlaintextEditor::eEditorDisabledMask) ||
          (flags & nsIPlaintextEditor::eEditorFilterInputMask))
        {
          selCon->SetDisplaySelection(nsISelectionController::SELECTION_HIDDEN);//hide but do NOT turn off
        }
        else
        {
          selCon->SetDisplaySelection(nsISelectionController::SELECTION_DISABLED);
        }

#ifdef USE_HACK_REPAINT
// begin hack repaint
        nsIViewManager* viewmgr = ps->GetViewManager();
        if (viewmgr) 
        {
          nsIView* view;
          viewmgr->GetRootView(view);         // views are not refCounted
          if (view) {
            viewmgr->UpdateView(view,NS_VMREFRESH_IMMEDIATE);
          }
        }
// end hack repaint
#else
        selCon->RepaintSelection(nsISelectionController::SELECTION_NORMAL);
#endif
      }
    }
  }
  return NS_OK;
}

Here is the call graph for this function:

Processes a focus event.

Parameters:
aMouseEvent
See also:
nsIDOMEvent.h
Returns:
whether the event was consumed or ignored.
See also:
nsresult

Implements nsIDOMFocusListener.

Definition at line 1002 of file nsEditorEventListeners.cpp.

{
  NS_ENSURE_ARG(aEvent);
  // It's possible for us to receive a focus when we're really not focused.
  // This happens, for example, when an onfocus handler that's hooked up
  // before this listener focuses something else.  In that case, all of the
  // onblur handlers will be fired synchronously, then the remaining focus
  // handlers will be fired from the original event.  So, check to see that
  // we're really focused.  (Note that the analogous situation does not
  // happen for blurs, due to the ordering in
  // nsEventStateManager::SendFocuBlur().

  nsCOMPtr<nsIDOMEventTarget> target;
  aEvent->GetTarget(getter_AddRefs(target));
  if (!IsTargetFocused(target))
    return NS_OK;

  // turn on selection and caret
  if (mEditor)
  {
    aEvent->StopPropagation();

    PRUint32 flags;
    mEditor->GetFlags(&flags);
    if (! (flags & nsIPlaintextEditor::eEditorDisabledMask))
    { // only enable caret and selection if the editor is not disabled
      nsCOMPtr<nsIEditor>editor = do_QueryInterface(mEditor);
      if (editor)
      {
        nsCOMPtr<nsISelectionController>selCon;
        editor->GetSelectionController(getter_AddRefs(selCon));
        if (selCon)
        {
          if (! (flags & nsIPlaintextEditor::eEditorReadonlyMask)) {
            selCon->SetCaretEnabled(PR_TRUE);
          }

          selCon->SetDisplaySelection(nsISelectionController::SELECTION_ON);
#ifdef USE_HACK_REPAINT
  // begin hack repaint
          nsIViewManager* viewmgr = ps->GetViewManager();
          if (viewmgr) {
            nsIView* view;
            viewmgr->GetRootView(view);         // views are not refCounted
            if (view) {
              viewmgr->UpdateView(view,NS_VMREFRESH_IMMEDIATE);
            }
          }
  // end hack repaint
#else
          selCon->RepaintSelection(nsISelectionController::SELECTION_NORMAL);
#endif
        }
      }
    }

    nsCOMPtr<nsIEditorIMESupport> imeEditor = do_QueryInterface(mEditor);
    if (imeEditor)
      imeEditor->NotifyIMEOnFocus();
  }
  return NS_OK;
}

Here is the call graph for this function:

This method is called whenever an event occurs of the type for which the EventListener interface was registered.

Parameters:
evtThe Event contains contextual information about the event. It also contains the stopPropagation and preventDefault methods which are used in determining the event's flow and default action.

Definition at line 964 of file nsEditorEventListeners.cpp.

{
  return NS_OK;
}

SetEditor gives an address to the editor that will be accessed.

Parameters:
aEditorthe editor this listener calls for editing operations

Definition at line 257 of file nsEditorEventListeners.h.

{mEditor = aEditor;}

Here is the caller graph for this function:


Member Data Documentation

Definition at line 269 of file nsEditorEventListeners.h.


The documentation for this class was generated from the following files: