fixed disabled and readonly handling

added redraw hack to blur (in addition to focus, already done)
This commit is contained in:
buster%netscape.com 1999-08-07 05:28:57 +00:00
parent 6bc1c334be
commit 554895cb53
2 changed files with 64 additions and 48 deletions

View File

@ -1431,35 +1431,43 @@ nsTextEditorFocusListener::Focus(nsIDOMEvent* aEvent)
// turn on selection and caret
if (mEditor)
{
nsCOMPtr<nsIEditor>editor = do_QueryInterface(mEditor);
if (editor)
{
nsCOMPtr<nsIPresShell>ps;
editor->GetPresShell(getter_AddRefs(ps));
if (ps)
PRUint32 flags;
mEditor->GetFlags(&flags);
if (! (flags & TEXT_EDITOR_FLAG_DISABLED))
{ // only enable caret and selection if the editor is not disabled
nsCOMPtr<nsIEditor>editor = do_QueryInterface(mEditor);
if (editor)
{
ps->SetCaretEnabled(PR_TRUE);
nsCOMPtr<nsIDOMDocument>domDoc;
editor->GetDocument(getter_AddRefs(domDoc));
if (domDoc)
nsCOMPtr<nsIPresShell>ps;
editor->GetPresShell(getter_AddRefs(ps));
if (ps)
{
nsCOMPtr<nsIDocument>doc = do_QueryInterface(domDoc);
if (doc)
if (! (flags & TEXT_EDITOR_FLAG_READONLY))
{ // only enable caret if the editor is not readonly
ps->SetCaretEnabled(PR_TRUE);
}
nsCOMPtr<nsIDOMDocument>domDoc;
editor->GetDocument(getter_AddRefs(domDoc));
if (domDoc)
{
doc->SetDisplaySelection(PR_TRUE);
nsCOMPtr<nsIDocument>doc = do_QueryInterface(domDoc);
if (doc)
{
doc->SetDisplaySelection(PR_TRUE);
}
}
}
// begin hack repaint
nsCOMPtr<nsIViewManager> viewmgr;
ps->GetViewManager(getter_AddRefs(viewmgr));
if (viewmgr) {
nsIView* view;
viewmgr->GetRootView(view); // views are not refCounted
if (view) {
viewmgr->UpdateView(view,nsnull,NS_VMREFRESH_IMMEDIATE);
// begin hack repaint
nsCOMPtr<nsIViewManager> viewmgr;
ps->GetViewManager(getter_AddRefs(viewmgr));
if (viewmgr) {
nsIView* view;
viewmgr->GetRootView(view); // views are not refCounted
if (view) {
viewmgr->UpdateView(view,nsnull,NS_VMREFRESH_IMMEDIATE);
}
// end hack repaint
}
// end hack repaint
}
}
}

View File

@ -1431,35 +1431,43 @@ nsTextEditorFocusListener::Focus(nsIDOMEvent* aEvent)
// turn on selection and caret
if (mEditor)
{
nsCOMPtr<nsIEditor>editor = do_QueryInterface(mEditor);
if (editor)
{
nsCOMPtr<nsIPresShell>ps;
editor->GetPresShell(getter_AddRefs(ps));
if (ps)
PRUint32 flags;
mEditor->GetFlags(&flags);
if (! (flags & TEXT_EDITOR_FLAG_DISABLED))
{ // only enable caret and selection if the editor is not disabled
nsCOMPtr<nsIEditor>editor = do_QueryInterface(mEditor);
if (editor)
{
ps->SetCaretEnabled(PR_TRUE);
nsCOMPtr<nsIDOMDocument>domDoc;
editor->GetDocument(getter_AddRefs(domDoc));
if (domDoc)
nsCOMPtr<nsIPresShell>ps;
editor->GetPresShell(getter_AddRefs(ps));
if (ps)
{
nsCOMPtr<nsIDocument>doc = do_QueryInterface(domDoc);
if (doc)
if (! (flags & TEXT_EDITOR_FLAG_READONLY))
{ // only enable caret if the editor is not readonly
ps->SetCaretEnabled(PR_TRUE);
}
nsCOMPtr<nsIDOMDocument>domDoc;
editor->GetDocument(getter_AddRefs(domDoc));
if (domDoc)
{
doc->SetDisplaySelection(PR_TRUE);
nsCOMPtr<nsIDocument>doc = do_QueryInterface(domDoc);
if (doc)
{
doc->SetDisplaySelection(PR_TRUE);
}
}
}
// begin hack repaint
nsCOMPtr<nsIViewManager> viewmgr;
ps->GetViewManager(getter_AddRefs(viewmgr));
if (viewmgr) {
nsIView* view;
viewmgr->GetRootView(view); // views are not refCounted
if (view) {
viewmgr->UpdateView(view,nsnull,NS_VMREFRESH_IMMEDIATE);
// begin hack repaint
nsCOMPtr<nsIViewManager> viewmgr;
ps->GetViewManager(getter_AddRefs(viewmgr));
if (viewmgr) {
nsIView* view;
viewmgr->GetRootView(view); // views are not refCounted
if (view) {
viewmgr->UpdateView(view,nsnull,NS_VMREFRESH_IMMEDIATE);
}
// end hack repaint
}
// end hack repaint
}
}
}