summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGergo Mocsi <gmocsi91@gmail.com>2013-07-21 19:36:56 +0200
committerGergo Mocsi <gmocsi91@gmail.com>2013-07-21 19:36:56 +0200
commit5692833cb94cbfe8a456007d8674f87c24c4efa0 (patch)
treeb8c17a35993955a98ab6e13086da105ce9e83360
parent623f0ecd35f96f2d047ae2f0461967407bb56cea (diff)
GSOC work window hide when clicking out
CodeCompleteWindow is hidden when clicking out: thi is implemented in EditorWindow::MouseButtonDown: if CodeCompleteWindow is visible and the actual TextSelection of the window and the parent's TextView is different, hide the window (I assume the user changed selection, eg. clicked on other line, etc.). Change-Id: Icb6bcffa837b2f7e1ccef288b9d762e27649410b
-rw-r--r--basctl/source/basicide/baside2.hxx5
-rw-r--r--basctl/source/basicide/baside2b.cxx34
2 files changed, 32 insertions, 7 deletions
diff --git a/basctl/source/basicide/baside2.hxx b/basctl/source/basicide/baside2.hxx
index eaf700bdb5b2..8737091ce614 100644
--- a/basctl/source/basicide/baside2.hxx
+++ b/basctl/source/basicide/baside2.hxx
@@ -518,6 +518,11 @@ public:
const TextSelection& GetTextSelection() const;
void ResizeListBox();
void SelectFirstEntry(); //selects first entry in ListBox
+ void ClearAndHide();
+ /*
+ * clears if typed anything, then hides
+ * the window, clear internal variables
+ * */
};
diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx
index c21be94b11e8..bfa82850117d 100644
--- a/basctl/source/basicide/baside2b.cxx
+++ b/basctl/source/basicide/baside2b.cxx
@@ -443,6 +443,13 @@ void EditorWindow::MouseButtonDown( const MouseEvent &rEvt )
GrabFocus();
if ( pEditView )
pEditView->MouseButtonDown( rEvt );
+ if( pCodeCompleteWnd->IsVisible() )
+ {
+ if( pEditView->GetSelection() != pCodeCompleteWnd->GetTextSelection() )
+ {//selection changed, code complete window should be hidden
+ pCodeCompleteWnd->ClearAndHide();
+ }
+ }
}
void EditorWindow::Command( const CommandEvent& rCEvt )
@@ -2367,8 +2374,8 @@ void CodeCompleteListBox::InsertSelectedEntry()
if( aFuncBuffer.toString() != OUString("") )
{
// if the user typed in something: remove, and insert
- TextPaM aEnd(pCodeCompleteWindow->aTextSelection.GetEnd().GetPara(), pCodeCompleteWindow->aTextSelection.GetEnd().GetIndex() + aFuncBuffer.getLength());
- TextPaM aStart(pCodeCompleteWindow->aTextSelection.GetEnd().GetPara(), pCodeCompleteWindow->aTextSelection.GetEnd().GetIndex() );
+ TextPaM aEnd(pCodeCompleteWindow->aTextSelection.GetEnd().GetPara(), pCodeCompleteWindow->GetTextSelection().GetEnd().GetIndex() + aFuncBuffer.getLength());
+ TextPaM aStart(pCodeCompleteWindow->aTextSelection.GetEnd().GetPara(), pCodeCompleteWindow->GetTextSelection().GetEnd().GetIndex() );
pCodeCompleteWindow->pParent->GetEditView()->SetSelection(TextSelection(aStart, aEnd));
pCodeCompleteWindow->pParent->GetEditView()->DeleteSelected();
@@ -2416,9 +2423,10 @@ long CodeCompleteListBox::PreNotify( NotifyEvent& rNEvt )
switch( aChar )
{
case KEY_ESCAPE: // hide, do nothing
- pCodeCompleteWindow->Hide();
+ pCodeCompleteWindow->ClearAndHide();
+ /*pCodeCompleteWindow->Hide();
pCodeCompleteWindow->pParent->GetEditView()->SetSelection( pCodeCompleteWindow->pParent->GetEditView()->CursorEndOfLine(pCodeCompleteWindow->GetTextSelection().GetStart()) );
- //pCodeCompleteWindow->pParent->GrabFocus();
+ //pCodeCompleteWindow->pParent->GrabFocus();*/
return 0;
case KEY_TAB: case KEY_SPACE:
/* space, tab the user probably have typed in the whole
@@ -2432,8 +2440,8 @@ long CodeCompleteListBox::PreNotify( NotifyEvent& rNEvt )
case KEY_BACKSPACE: case KEY_DELETE:
if( aFuncBuffer.toString() != OUString("") )
{
- TextPaM aEnd(pCodeCompleteWindow->aTextSelection.GetEnd().GetPara(), pCodeCompleteWindow->aTextSelection.GetEnd().GetIndex() + aFuncBuffer.getLength());
- TextPaM aStart(pCodeCompleteWindow->aTextSelection.GetEnd().GetPara(), pCodeCompleteWindow->aTextSelection.GetEnd().GetIndex() + aFuncBuffer.getLength()-1);
+ TextPaM aEnd(pCodeCompleteWindow->aTextSelection.GetEnd().GetPara(), pCodeCompleteWindow->GetTextSelection().GetEnd().GetIndex() + aFuncBuffer.getLength());
+ TextPaM aStart(pCodeCompleteWindow->aTextSelection.GetEnd().GetPara(), pCodeCompleteWindow->GetTextSelection().GetEnd().GetIndex() + aFuncBuffer.getLength()-1);
aFuncBuffer.stripEnd(aFuncBuffer[aFuncBuffer.getLength()-1]);
pCodeCompleteWindow->pParent->GetEditView()->SetSelection(TextSelection(aStart, aEnd));
pCodeCompleteWindow->pParent->GetEditView()->DeleteSelected();
@@ -2515,12 +2523,13 @@ void CodeCompleteWindow::ResizeListBox()
const Font& aFont = pListBox->GetUnzoomedControlPointFont();
aSize.setHeight( aFont.GetSize().getHeight() * 16 );
- aSize.setWidth( pListBox->CalcSize(aLongestEntry.getLength(),pListBox->GetEntryCount()).getWidth() );
+ aSize.setWidth( pListBox->CalcSize(aLongestEntry.getLength(), pListBox->GetEntryCount()).getWidth() );
pListBox->SetSizePixel( aSize );
aSize.setWidth( aSize.getWidth() + 1 );
aSize.setHeight( aSize.getHeight() + 1 );
SetSizePixel( aSize );
+ pListBox->GrabFocus();
}
}
@@ -2532,6 +2541,17 @@ void CodeCompleteWindow::SelectFirstEntry()
}
}
+void CodeCompleteWindow::ClearAndHide()
+{
+ TextPaM aEnd(aTextSelection.GetEnd().GetPara(), GetTextSelection().GetEnd().GetIndex() + pListBox->aFuncBuffer.getLength());
+ TextPaM aStart(aTextSelection.GetEnd().GetPara(), GetTextSelection().GetEnd().GetIndex() );
+ pParent->GetEditView()->SetSelection(TextSelection(aStart, aEnd));
+ pParent->GetEditView()->DeleteSelected();
+ Hide();
+ ClearListBox();
+ pParent->GrabFocus();
+}
+
} // namespace basctl
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */