Reworking internal event code to use nsIFrame::GetFrameForPoint

Adding new functionality through nsEventStateManager (cursor change, enter/exit events, tab navig)
This commit is contained in:
joki@netscape.com
1998-11-18 05:25:26 +00:00
parent 3b4b8a9793
commit 249a270b84
89 changed files with 1584 additions and 1266 deletions

View File

@@ -49,8 +49,9 @@
enum nsMouseState {
eMouseNone,
eMouseEnter,
eMouseExit,
eMouseDown,
eMouseExit
eMouseUp
};
static NS_DEFINE_IID(kIFormControlIID, NS_IFORMCONTROL_IID);
@@ -79,6 +80,8 @@ public:
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus);
NS_IMETHOD GetFrameForPoint(const nsPoint& aPoint, nsIFrame** aFrame);
NS_IMETHOD SetInitialChildList(nsIPresContext& aPresContext,
nsIAtom* aListName,
nsIFrame* aChildList);
@@ -428,7 +431,7 @@ nsHTMLButtonControlFrame::GetTranslatedRect(nsRect& aRect)
}
NS_METHOD
NS_IMETHODIMP
nsHTMLButtonControlFrame::HandleEvent(nsIPresContext& aPresContext,
nsGUIEvent* aEvent,
nsEventStatus& aEventStatus)
@@ -453,44 +456,16 @@ nsHTMLButtonControlFrame::HandleEvent(nsIPresContext& aPresContext,
PRBool ignore;
switch (aEvent->message) {
case NS_MOUSE_ENTER: // not implemented yet on frames, 1st mouse move simulates it
mLastMouseState = eMouseEnter;
case NS_MOUSE_ENTER:
if (mLastMouseState == eMouseDown) {
ShiftContents(aPresContext, PR_TRUE);
}
break;
case NS_MOUSE_LEFT_BUTTON_DOWN:
mGotFocus = PR_TRUE;
ShiftContents(aPresContext, PR_TRUE);
mLastMouseState = eMouseDown;
break;
case NS_MOUSE_MOVE:
//printf ("%d mRect=(%d,%d,%d,%d), x=%d, y=%d \n", foo++, mRect.x, mRect.y, mRect.width, mRect.height, aEvent->point.x, aEvent->point.y);
if (nsnull == grabber) { // simulated mouse enter
GetTranslatedRect(mTranslatedRect);
//printf("%d enter\n", foo++);
viewMan->GrabMouseEvents(view, ignore);
GetWindow(window);
if (window) {
mPreviousCursor = window->GetCursor();
window->SetCursor(eCursor_select); // set it to something else to work around bug
window->SetCursor(eCursor_standard);
NS_RELEASE(window);
}
mLastMouseState = eMouseEnter;
// simulated mouse exit
} else if (!mTranslatedRect.Contains(aEvent->point)) {
//printf("%d exit\n", foo++);
if (mLastMouseState == eMouseDown) { //
ShiftContents(aPresContext, PR_FALSE);
}
viewMan->GrabMouseEvents(nsnull, ignore);
GetWindow(window);
if (window) {
window->SetCursor(mPreviousCursor);
NS_RELEASE(window);
}
mLastMouseState = eMouseExit;
}
break;
case NS_MOUSE_LEFT_BUTTON_UP:
if (eMouseDown == mLastMouseState) {
ShiftContents(aPresContext, PR_FALSE);
@@ -503,27 +478,31 @@ nsHTMLButtonControlFrame::HandleEvent(nsIPresContext& aPresContext,
if (nsEventStatus_eConsumeNoDefault != status) {
MouseClicked(&aPresContext);
}
mLastMouseState = eMouseEnter;
mLastMouseState = eMouseUp;
}
break;
case NS_MOUSE_EXIT: // doesn't work for frames, yet
case NS_MOUSE_EXIT:
if (mLastMouseState == eMouseDown) {
ShiftContents(aPresContext, PR_FALSE);
}
break;
}
aEventStatus = nsEventStatus_eConsumeNoDefault;
NS_RELEASE(viewMan);
return NS_OK;
}
}
}
if (nsnull == mFirstChild) { // XXX see corresponding hack in nsHTMLContainerFrame::DeleteFrame
aEventStatus = nsEventStatus_eConsumeNoDefault;
return NS_OK;
} else {
return nsHTMLContainerFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
}
return NS_OK;
}
NS_IMETHODIMP
nsHTMLButtonControlFrame::GetFrameForPoint(const nsPoint& aPoint, nsIFrame** aFrame)
{
*aFrame = this;
return NS_OK;
}
NS_IMETHODIMP
nsHTMLButtonControlFrame::SetInitialChildList(nsIPresContext& aPresContext,
nsIAtom* aListName,