fix double-click bug (clicking twice quickly in scrollbar invokes properties dialogs); bug 134503, r=akkana, sr=kin, a=scc, adt=putterman

git-svn-id: svn://10.0.0.236/branches/MOZILLA_1_0_BRANCH@119750 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
brade%netscape.com
2002-04-24 21:32:12 +00:00
parent 6e2c371544
commit 699a315d5e
3 changed files with 68 additions and 8 deletions

View File

@@ -219,6 +219,43 @@ var DocumentReloadListener =
}
};
function addEditorClickEventListener()
{
try {
var bodyelement = GetBodyElement();
if (bodyelement)
bodyelement.addEventListener("click", EditorClick, false);
} catch (e) {}
}
var MessageComposeDocumentStateListener =
{
NotifyDocumentCreated: function()
{
addEditorClickEventListener();
},
NotifyDocumentWillBeDestroyed: function()
{
// note that the editorshell seems to be gone at this point
// so we don't have a way to remove the click listener.
// hopefully it is being cleaned up with all listeners
},
NotifyDocumentStateChanged:function()
{
}
};
function isPlaintextEditor()
{
var editorflags;
try {
editorflags = window.editorShell.editor.flags;
} catch(e) {}
return (editorflags & Components.interfaces.nsIPlaintextEditor.eEditorPlaintextMask);
}
// This is called when the real editor document is created,
// before it's loaded.
@@ -245,9 +282,17 @@ var DocumentStateListener =
// We must wait until document is created to get proper Url
// (Windows may load with local file paths)
SetSaveAndPublishUI(GetDocumentUrl());
// Add mouse click watcher if right type of editor
if (!isPlaintextEditor())
addEditorClickEventListener();
},
// note that the editorshell seems to be gone at this point
// so we don't have a way to remove the click listener.
// hopefully it is being cleaned up with all listeners
NotifyDocumentWillBeDestroyed: function() {},
NotifyDocumentStateChanged:function( isNowDirty )
{
/* Notify our dirty detector so this window won't be closed if
@@ -293,9 +338,6 @@ function EditorStartup(editorType, editorElement)
editorShell.webShellWindow = window;
editorShell.contentWindow = window._content;
// add a listener to be called when document is really done loading
editorShell.RegisterDocumentStateListener( DocumentStateListener );
// set up our global prefs object
GetPrefsService();
@@ -331,12 +373,23 @@ function EditorSharedStartup()
case "htmlmail":
SetupHTMLEditorCommands();
editorShell.contentsMIMEType = "text/html";
if (editorShell.editorType == "htmlmail")
editorShell.RegisterDocumentStateListener( MessageComposeDocumentStateListener );
else
// add a listener to be called when document is really done loading
editorShell.RegisterDocumentStateListener( DocumentStateListener );
break;
case "text":
// add listener when document is done loading (for toolbar setup)
editorShell.RegisterDocumentStateListener( DocumentStateListener );
// continue below
case "textmail":
SetupTextEditorCommands();
editorShell.contentsMIMEType = "text/plain";
break;
default:
dump("INVALID EDITOR TYPE: "+editorShell.editorType+"\n");
SetupTextEditorCommands();
@@ -1265,10 +1318,19 @@ function EditorDblClick(event)
function EditorClick(event)
{
if (!event)
return;
if (event.detail == 2)
{
EditorDblClick(event);
return;
}
// In Show All Tags Mode,
// single click selects entire element,
// except for body and table elements
if (event && event.target && gEditorDisplayMode == DisplayModeAllTags)
if (event.target && gEditorDisplayMode == DisplayModeAllTags)
{
try {
var element = event.target.QueryInterface( Components.interfaces.nsIDOMElement);

View File

@@ -244,8 +244,7 @@
which breaks deck frame-hiding mechanism
-->
<stack>
<editor type="content-primary" id="content-frame" src="about:blank" context="editorContentContext" flex="1"
onclick="EditorClick(event);" ondblclick="EditorDblClick(event);"/>
<editor type="content-primary" id="content-frame" src="about:blank" context="editorContentContext" flex="1"/>
</stack>
<vbox>
<label id="doctype-text" crop="right"/>

View File

@@ -476,8 +476,7 @@
<!-- The mail message body frame -->
<vbox id="appcontent" flex="1">
<editor type="content-primary" id="content-frame" src="about:blank" name="browser.message.body" flex="1"
onkeypress="editorKeyPress(event);" context="msgComposeContext"
ondblclick="EditorDblClick(event);"/>
onkeypress="editorKeyPress(event);" context="msgComposeContext"/>
</vbox>
<statusbar id="status-bar" class="chromeclass-status">