Back to index

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

#include <mozXMLTermListeners.h>

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

List of all members.

Public Member Functions

 mozXMLTermMouseListener ()
virtual ~mozXMLTermMouseListener ()
void SetXMLTerminal (mozIXMLTerminal *aXMLTerminal)
 Save non-owning reference to containing XMLTerminal object.
virtual NS_DECL_ISUPPORTS nsresult HandleEvent (nsIDOMEvent *aEvent)
virtual nsresult MouseDown (nsIDOMEvent *aMouseEvent)
 Processes a mouse down event.
virtual nsresult MouseUp (nsIDOMEvent *aMouseEvent)
 Processes a mouse up event.
virtual nsresult MouseClick (nsIDOMEvent *aMouseEvent)
 Processes a mouse click event.
virtual nsresult MouseDblClick (nsIDOMEvent *aMouseEvent)
 Processes a mouse click event.
virtual nsresult MouseOver (nsIDOMEvent *aMouseEvent)
 Processes a mouse enter event.
virtual nsresult MouseOut (nsIDOMEvent *aMouseEvent)
 Processes a mouse leave 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

mozIXMLTerminalmXMLTerminal
 non-owning reference to containing XMLTerminal object (for callback)

Detailed Description

Definition at line 123 of file mozXMLTermListeners.h.


Constructor & Destructor Documentation

Definition at line 528 of file mozXMLTermListeners.cpp.

{
}

Definition at line 533 of file mozXMLTermListeners.cpp.

{
}

Member Function Documentation

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 574 of file mozXMLTermListeners.cpp.

{
  return NS_OK;
}

Processes a mouse click event.

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

Implements nsIDOMMouseListener.

Definition at line 616 of file mozXMLTermListeners.cpp.

{
  nsresult result;

  if (!aMouseEvent)
    return NS_OK;

  nsCOMPtr<nsIDOMMouseEvent> mouseEvent;
  mouseEvent = do_QueryInterface(aMouseEvent);
  if (!mouseEvent) {
    // Non-mouse event passed; do not consume it
    return NS_OK;
  }

  PRUint16 buttonCode = (PRUint16)-1;
  mouseEvent->GetButton(&buttonCode);

  PRInt32 screenX, screenY;
  result = mouseEvent->GetScreenX(&screenX);
  result = mouseEvent->GetScreenY(&screenY);

  XMLT_LOG(mozXMLTermMouseListener::MouseClick,50, ("buttonCode=%d\n",
                                                    buttonCode));

#if 0
  // NO MORE NEED FOR THIS WORKAROUND!
  // Without this workaround, clicking on the xmlterm window to give it
  // focus fails position the cursor at the end of the last line
  // (For some reason, the MouseDown event causes the cursor to be positioned
  // in the line above the location of the mouse click

  // Get selection
  nsCOMPtr<nsIPresShell> presShell;
  result = mXMLTerminal->GetPresShell(getter_AddRefs(presShell));
  if (NS_FAILED(result) || !presShell)
    return NS_OK; // Do not consume mouse event
  nsCOMPtr<nsISelectionController> selCon;
  selCon = do_QueryInterface(presShell);
  if (!selCon)
    return NS_ERROR_FAILURE;
  nsCOMPtr<nsISelection> selection;
  result = selCon->GetSelection(nsISelectionController::SELECTION_NORMAL,
                                     getter_AddRefs(selection));

  if (NS_FAILED(result) || !selection)
    return NS_OK; // Do not consume mouse event

  PRBool isCollapsed;
  result = selection->GetIsCollapsed(&isCollapsed);
  if (NS_FAILED(result))
    return NS_OK; // Do not consume mouse event

  XMLT_LOG(mozXMLTermMouseListener::MouseClick,50, ("isCollapsed=%d\n",
                                                    isCollapsed));

  // If non-collapsed selection, do not collapse it
  if (!isCollapsed)
    return NS_OK;

  // Locate selection range
  nsCOMPtr<nsIDOMNSUIEvent> uiEvent (do_QueryInterface(mouseEvent));
  if (!uiEvent)
    return NS_OK; // Do not consume mouse event

  nsCOMPtr<nsIDOMNode> parentNode;
  result = uiEvent->GetRangeParent(getter_AddRefs(parentNode));
  if (NS_FAILED(result) || !parentNode)
    return NS_OK; // Do not consume mouse event

  PRInt32 offset = 0;
  result = uiEvent->GetRangeOffset(&offset);
  if (NS_FAILED(result))
    return NS_OK; // Do not consume mouse event

  (void)selection->Collapse(parentNode, offset);
#endif

  return NS_OK; // Do not consume mouse event
}

Here is the call graph for this function:

Processes a mouse click event.

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

Implements nsIDOMMouseListener.

Definition at line 698 of file mozXMLTermListeners.cpp.

{
  return NS_OK;
}

Processes a mouse down event.

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

Implements nsIDOMMouseListener.

Definition at line 581 of file mozXMLTermListeners.cpp.

{
  if (!aMouseEvent)
    return NS_OK;

  nsCOMPtr<nsIDOMMouseEvent> mouseEvent;
  mouseEvent = do_QueryInterface(aMouseEvent);
  if (!mouseEvent) {
    // Non-mouse event passed; do not consume it
    return NS_OK;
  }

  PRUint16 buttonCode = (PRUint16)-1;
  mouseEvent->GetButton(&buttonCode);

  XMLT_LOG(mozXMLTermMouseListener::MouseDown,50,("buttonCode=%d\n",
                                                  buttonCode));

  if (buttonCode == 1) {
    // Middle-mouse button pressed; initiate paste
    mXMLTerminal->Paste();
  }

  return NS_OK;
}

Here is the call graph for this function:

Processes a mouse leave event.

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

Implements nsIDOMMouseListener.

Definition at line 712 of file mozXMLTermListeners.cpp.

{
  return NS_OK;
}

Processes a mouse enter event.

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

Implements nsIDOMMouseListener.

Definition at line 705 of file mozXMLTermListeners.cpp.

{
  return NS_OK;
}

Processes a mouse up event.

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

Implements nsIDOMMouseListener.

Definition at line 609 of file mozXMLTermListeners.cpp.

{
  return NS_OK;
}

Save non-owning reference to containing XMLTerminal object.

Parameters:
aXMLTerminalthe XMLTerm instance

Definition at line 131 of file mozXMLTermListeners.h.

    {mXMLTerminal = aXMLTerminal;}

Here is the caller graph for this function:


Member Data Documentation

non-owning reference to containing XMLTerminal object (for callback)

Definition at line 150 of file mozXMLTermListeners.h.


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