diff options
author | Gergo Mocsi <gmocsi91@gmail.com> | 2013-07-21 19:36:56 +0200 |
---|---|---|
committer | Gergo Mocsi <gmocsi91@gmail.com> | 2013-09-02 18:16:46 +0200 |
commit | 1b8b4864c11955a2f59310cc58f16e509eb48a32 (patch) | |
tree | ffacc930d327661bf974771f987bcd878b6bfe5d /basctl | |
parent | 6165d0b4846590d1d85d559636dd6587ea0dadd8 (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
Diffstat (limited to 'basctl')
-rw-r--r-- | basctl/source/basicide/baside2.hxx | 5 | ||||
-rw-r--r-- | basctl/source/basicide/baside2b.cxx | 34 |
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 d3006427939d..880578d742f0 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 ) @@ -2373,8 +2380,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(); @@ -2422,9 +2429,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 @@ -2438,8 +2446,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(); @@ -2521,12 +2529,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(); } } @@ -2538,6 +2547,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: */ |