summaryrefslogtreecommitdiff
path: root/basctl
diff options
context:
space:
mode:
authorGergo Mocsi <gmocsi91@gmail.com>2013-08-02 12:32:13 +0200
committerGergo Mocsi <gmocsi91@gmail.com>2013-09-02 18:16:54 +0200
commita1c1e89e43a8c3815d6029a2438c57ef8d1f98cb (patch)
tree6fd1d2917394e48a8b936f7dfdb9730297a19632 /basctl
parentcbd61c3047a7df1c2995ef3ce1acf55b6950af76 (diff)
GSOC work, show the cursor when typing 2
There are two cases: a) TextView in focus: cursor is visible, typing works, except the arrow keys are not working for the ListBox b) ListBox in focus: no cursor, everything works Change-Id: Iaaec69c04370e4d05e226abeecd420bf4d4f52cd
Diffstat (limited to 'basctl')
-rw-r--r--basctl/source/basicide/baside2.hxx8
-rw-r--r--basctl/source/basicide/baside2b.cxx73
2 files changed, 81 insertions, 0 deletions
diff --git a/basctl/source/basicide/baside2.hxx b/basctl/source/basicide/baside2.hxx
index 42904b2478a9..5618f7618cc7 100644
--- a/basctl/source/basicide/baside2.hxx
+++ b/basctl/source/basicide/baside2.hxx
@@ -76,6 +76,7 @@ void setTextEngineText (ExtTextEngine&, OUString const&);
class EditorWindow : public Window, public SfxListener
{
+friend class CodeCompleteListBox;
private:
class ChangesListener;
@@ -475,6 +476,7 @@ private:
class CodeCompleteListBox: public ListBox
{
friend class CodeCompleteWindow;
+friend class EditorWindow;
private:
OUStringBuffer aFuncBuffer;
/* a buffer to build up function name when typing
@@ -489,9 +491,12 @@ public:
void InsertSelectedEntry(); //insert the selected entry
DECL_LINK(ImplDoubleClickHdl, void*);
+ //DECL_LINK(ImplSelectionChangeHdl, void*);
virtual long PreNotify( NotifyEvent& rNEvt );
+protected:
+ virtual void KeyInput( const KeyEvent& rKeyEvt );
};
class CodeCompleteWindow: public Window
@@ -519,6 +524,9 @@ public:
* clears if typed anything, then hides
* the window, clear internal variables
* */
+ OUStringBuffer& GetListBoxBuffer();
+ void SetVisibleEntries(); // sets the visible entries based on aFuncBuffer variable
+ CodeCompleteListBox* GetListBox(){return pListBox;}
};
diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx
index 1f9889150f51..00b048d26cf1 100644
--- a/basctl/source/basicide/baside2b.cxx
+++ b/basctl/source/basicide/baside2b.cxx
@@ -508,6 +508,13 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
// see if there is an accelerator to be processed first
bool bDone = SfxViewShell::Current()->KeyInput( rKEvt );
+ //sal_Unicode aChar = rKEvt.GetKeyCode().GetCode();
+ if( pCodeCompleteWnd->IsVisible() )
+ {
+ std::cerr << "EditorWindow::KeyInput" << std::endl;
+ pCodeCompleteWnd->GetListBox()->KeyInput(rKEvt);
+ }
+
if( (rKEvt.GetKeyCode().GetCode() == KEY_SPACE ||
rKEvt.GetKeyCode().GetCode() == KEY_TAB ||
rKEvt.GetKeyCode().GetCode() == KEY_RETURN ) && CodeCompleteOptions::IsAutoCorrectKeywordsOn() )
@@ -763,6 +770,7 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
pCodeCompleteWnd->ResizeListBox();
pCodeCompleteWnd->SelectFirstEntry();
pEditView->GetWindow()->GrabFocus();
+ //pEditView->EnableCursor( true );
}
}
}
@@ -2544,6 +2552,7 @@ CodeCompleteListBox::CodeCompleteListBox( CodeCompleteWindow* pPar )
pCodeCompleteWindow( pPar )
{
SetDoubleClickHdl(LINK(this, CodeCompleteListBox, ImplDoubleClickHdl));
+ //SetSelectHdl(LINK(this, CodeCompleteListBox, ImplSelectionChangeHdl));
}
IMPL_LINK_NOARG(CodeCompleteListBox, ImplDoubleClickHdl)
@@ -2552,6 +2561,12 @@ IMPL_LINK_NOARG(CodeCompleteListBox, ImplDoubleClickHdl)
return 0;
}
+/*IMPL_LINK_NOARG(CodeCompleteListBox, ImplSelectionChangeHdl)
+{
+ pCodeCompleteWindow->pParent->GrabFocus();
+ return 0;
+}*/
+
void CodeCompleteListBox::InsertSelectedEntry()
{
if( !aFuncBuffer.toString().isEmpty() )
@@ -2592,6 +2607,7 @@ long CodeCompleteListBox::PreNotify( NotifyEvent& rNEvt )
{
if( rNEvt.GetType() == EVENT_KEYINPUT )
{
+ std::cerr << "CodeCompleteListBox::PreNotify" << std::endl;
KeyEvent aKeyEvt = *rNEvt.GetKeyEvent();
sal_Unicode aChar = aKeyEvt.GetKeyCode().GetCode();
if( ( aChar >= KEY_A ) && ( aChar <= KEY_Z ) )
@@ -2599,6 +2615,7 @@ long CodeCompleteListBox::PreNotify( NotifyEvent& rNEvt )
pCodeCompleteWindow->pParent->GetEditView()->InsertText( OUString(aKeyEvt.GetCharCode()) );
aFuncBuffer.append(aKeyEvt.GetCharCode());
SetVisibleEntries();
+ //pCodeCompleteWindow->pParent->GetEditView()->GetWindow()->GrabFocus();
return 0;
}
else
@@ -2635,9 +2652,13 @@ long CodeCompleteListBox::PreNotify( NotifyEvent& rNEvt )
case KEY_RETURN:
InsertSelectedEntry();
return 0;
+ /*case KEY_UP: case KEY_DOWN:
+ std::cerr << "up/down ke in PreNotify" << std::endl;
+ break;*/
}
}
}
+ //pCodeCompleteWindow->pParent->GrabFocus();
return ListBox::PreNotify( rNEvt );
}
@@ -2654,6 +2675,48 @@ void CodeCompleteListBox::SetVisibleEntries()
}
}
+void CodeCompleteListBox::KeyInput( const KeyEvent& rKeyEvt )
+{
+ std::cerr << "CodeCompleteListBox::KeyInput" << std::endl;
+ //pCodeCompleteWindow->pParent->GetEditView()->KeyInput( rKeyEvt );
+ sal_Unicode aChar = rKeyEvt.GetKeyCode().GetCode();
+ if( ( aChar >= KEY_A ) && ( aChar <= KEY_Z ) )
+ {
+ //pCodeCompleteWindow->pParent->GetEditView()->InsertText( OUString(rKeyEvt.GetCharCode()) );
+ aFuncBuffer.append(rKeyEvt.GetCharCode());
+ SetVisibleEntries();
+ }
+ else
+ {
+ switch( aChar )
+ {
+ case KEY_ESCAPE: // hide, do nothing
+ pCodeCompleteWindow->ClearAndHide();
+ break;
+ case KEY_TAB: case KEY_SPACE:
+ pCodeCompleteWindow->Hide();
+ pCodeCompleteWindow->pParent->GetEditView()->SetSelection( pCodeCompleteWindow->pParent->GetEditView()->CursorEndOfLine(pCodeCompleteWindow->GetTextSelection().GetStart()) );
+ pCodeCompleteWindow->pParent->GrabFocus();
+ break;
+ case KEY_BACKSPACE: case KEY_DELETE:
+ if( aFuncBuffer.toString() != OUString("") )
+ {
+ aFuncBuffer = aFuncBuffer.remove(aFuncBuffer.getLength()-1, 1);
+ SetVisibleEntries();
+ }
+ else
+ {
+ pCodeCompleteWindow->ClearAndHide();
+ }
+ break;
+ case KEY_RETURN:
+ InsertSelectedEntry();
+ break;
+ }
+ }
+ ListBox::KeyInput(rKeyEvt);
+}
+
CodeCompleteWindow::CodeCompleteWindow( EditorWindow* pPar )
: Window( pPar ),
pParent( pPar ),
@@ -2663,6 +2726,11 @@ pListBox( new CodeCompleteListBox(this) )
InitListBox();
}
+OUStringBuffer& CodeCompleteWindow::GetListBoxBuffer()
+{
+ return pListBox->aFuncBuffer;
+}
+
void CodeCompleteWindow::InitListBox()
{
pListBox->SetSizePixel( Size(150,150) ); //default, this will adopt the line length
@@ -2754,6 +2822,11 @@ void CodeCompleteWindow::ClearAndHide()
pParent->GrabFocus();
}
+void CodeCompleteWindow::SetVisibleEntries()
+{
+ pListBox->SetVisibleEntries();
+}
+
} // namespace basctl
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */