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
This commit is contained in:
parent
cbd61c3047
commit
a1c1e89e43
@ -76,6 +76,7 @@ void setTextEngineText (ExtTextEngine&, OUString const&);
|
|||||||
|
|
||||||
class EditorWindow : public Window, public SfxListener
|
class EditorWindow : public Window, public SfxListener
|
||||||
{
|
{
|
||||||
|
friend class CodeCompleteListBox;
|
||||||
private:
|
private:
|
||||||
class ChangesListener;
|
class ChangesListener;
|
||||||
|
|
||||||
@ -475,6 +476,7 @@ private:
|
|||||||
class CodeCompleteListBox: public ListBox
|
class CodeCompleteListBox: public ListBox
|
||||||
{
|
{
|
||||||
friend class CodeCompleteWindow;
|
friend class CodeCompleteWindow;
|
||||||
|
friend class EditorWindow;
|
||||||
private:
|
private:
|
||||||
OUStringBuffer aFuncBuffer;
|
OUStringBuffer aFuncBuffer;
|
||||||
/* a buffer to build up function name when typing
|
/* a buffer to build up function name when typing
|
||||||
@ -489,9 +491,12 @@ public:
|
|||||||
void InsertSelectedEntry(); //insert the selected entry
|
void InsertSelectedEntry(); //insert the selected entry
|
||||||
|
|
||||||
DECL_LINK(ImplDoubleClickHdl, void*);
|
DECL_LINK(ImplDoubleClickHdl, void*);
|
||||||
|
//DECL_LINK(ImplSelectionChangeHdl, void*);
|
||||||
|
|
||||||
virtual long PreNotify( NotifyEvent& rNEvt );
|
virtual long PreNotify( NotifyEvent& rNEvt );
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void KeyInput( const KeyEvent& rKeyEvt );
|
||||||
};
|
};
|
||||||
|
|
||||||
class CodeCompleteWindow: public Window
|
class CodeCompleteWindow: public Window
|
||||||
@ -519,6 +524,9 @@ public:
|
|||||||
* clears if typed anything, then hides
|
* clears if typed anything, then hides
|
||||||
* the window, clear internal variables
|
* the window, clear internal variables
|
||||||
* */
|
* */
|
||||||
|
OUStringBuffer& GetListBoxBuffer();
|
||||||
|
void SetVisibleEntries(); // sets the visible entries based on aFuncBuffer variable
|
||||||
|
CodeCompleteListBox* GetListBox(){return pListBox;}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -508,6 +508,13 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
|
|||||||
// see if there is an accelerator to be processed first
|
// see if there is an accelerator to be processed first
|
||||||
bool bDone = SfxViewShell::Current()->KeyInput( rKEvt );
|
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 ||
|
if( (rKEvt.GetKeyCode().GetCode() == KEY_SPACE ||
|
||||||
rKEvt.GetKeyCode().GetCode() == KEY_TAB ||
|
rKEvt.GetKeyCode().GetCode() == KEY_TAB ||
|
||||||
rKEvt.GetKeyCode().GetCode() == KEY_RETURN ) && CodeCompleteOptions::IsAutoCorrectKeywordsOn() )
|
rKEvt.GetKeyCode().GetCode() == KEY_RETURN ) && CodeCompleteOptions::IsAutoCorrectKeywordsOn() )
|
||||||
@ -763,6 +770,7 @@ void EditorWindow::KeyInput( const KeyEvent& rKEvt )
|
|||||||
pCodeCompleteWnd->ResizeListBox();
|
pCodeCompleteWnd->ResizeListBox();
|
||||||
pCodeCompleteWnd->SelectFirstEntry();
|
pCodeCompleteWnd->SelectFirstEntry();
|
||||||
pEditView->GetWindow()->GrabFocus();
|
pEditView->GetWindow()->GrabFocus();
|
||||||
|
//pEditView->EnableCursor( true );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2544,6 +2552,7 @@ CodeCompleteListBox::CodeCompleteListBox( CodeCompleteWindow* pPar )
|
|||||||
pCodeCompleteWindow( pPar )
|
pCodeCompleteWindow( pPar )
|
||||||
{
|
{
|
||||||
SetDoubleClickHdl(LINK(this, CodeCompleteListBox, ImplDoubleClickHdl));
|
SetDoubleClickHdl(LINK(this, CodeCompleteListBox, ImplDoubleClickHdl));
|
||||||
|
//SetSelectHdl(LINK(this, CodeCompleteListBox, ImplSelectionChangeHdl));
|
||||||
}
|
}
|
||||||
|
|
||||||
IMPL_LINK_NOARG(CodeCompleteListBox, ImplDoubleClickHdl)
|
IMPL_LINK_NOARG(CodeCompleteListBox, ImplDoubleClickHdl)
|
||||||
@ -2552,6 +2561,12 @@ IMPL_LINK_NOARG(CodeCompleteListBox, ImplDoubleClickHdl)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*IMPL_LINK_NOARG(CodeCompleteListBox, ImplSelectionChangeHdl)
|
||||||
|
{
|
||||||
|
pCodeCompleteWindow->pParent->GrabFocus();
|
||||||
|
return 0;
|
||||||
|
}*/
|
||||||
|
|
||||||
void CodeCompleteListBox::InsertSelectedEntry()
|
void CodeCompleteListBox::InsertSelectedEntry()
|
||||||
{
|
{
|
||||||
if( !aFuncBuffer.toString().isEmpty() )
|
if( !aFuncBuffer.toString().isEmpty() )
|
||||||
@ -2592,6 +2607,7 @@ long CodeCompleteListBox::PreNotify( NotifyEvent& rNEvt )
|
|||||||
{
|
{
|
||||||
if( rNEvt.GetType() == EVENT_KEYINPUT )
|
if( rNEvt.GetType() == EVENT_KEYINPUT )
|
||||||
{
|
{
|
||||||
|
std::cerr << "CodeCompleteListBox::PreNotify" << std::endl;
|
||||||
KeyEvent aKeyEvt = *rNEvt.GetKeyEvent();
|
KeyEvent aKeyEvt = *rNEvt.GetKeyEvent();
|
||||||
sal_Unicode aChar = aKeyEvt.GetKeyCode().GetCode();
|
sal_Unicode aChar = aKeyEvt.GetKeyCode().GetCode();
|
||||||
if( ( aChar >= KEY_A ) && ( aChar <= KEY_Z ) )
|
if( ( aChar >= KEY_A ) && ( aChar <= KEY_Z ) )
|
||||||
@ -2599,6 +2615,7 @@ long CodeCompleteListBox::PreNotify( NotifyEvent& rNEvt )
|
|||||||
pCodeCompleteWindow->pParent->GetEditView()->InsertText( OUString(aKeyEvt.GetCharCode()) );
|
pCodeCompleteWindow->pParent->GetEditView()->InsertText( OUString(aKeyEvt.GetCharCode()) );
|
||||||
aFuncBuffer.append(aKeyEvt.GetCharCode());
|
aFuncBuffer.append(aKeyEvt.GetCharCode());
|
||||||
SetVisibleEntries();
|
SetVisibleEntries();
|
||||||
|
//pCodeCompleteWindow->pParent->GetEditView()->GetWindow()->GrabFocus();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -2635,9 +2652,13 @@ long CodeCompleteListBox::PreNotify( NotifyEvent& rNEvt )
|
|||||||
case KEY_RETURN:
|
case KEY_RETURN:
|
||||||
InsertSelectedEntry();
|
InsertSelectedEntry();
|
||||||
return 0;
|
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 );
|
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 )
|
CodeCompleteWindow::CodeCompleteWindow( EditorWindow* pPar )
|
||||||
: Window( pPar ),
|
: Window( pPar ),
|
||||||
pParent( pPar ),
|
pParent( pPar ),
|
||||||
@ -2663,6 +2726,11 @@ pListBox( new CodeCompleteListBox(this) )
|
|||||||
InitListBox();
|
InitListBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OUStringBuffer& CodeCompleteWindow::GetListBoxBuffer()
|
||||||
|
{
|
||||||
|
return pListBox->aFuncBuffer;
|
||||||
|
}
|
||||||
|
|
||||||
void CodeCompleteWindow::InitListBox()
|
void CodeCompleteWindow::InitListBox()
|
||||||
{
|
{
|
||||||
pListBox->SetSizePixel( Size(150,150) ); //default, this will adopt the line length
|
pListBox->SetSizePixel( Size(150,150) ); //default, this will adopt the line length
|
||||||
@ -2754,6 +2822,11 @@ void CodeCompleteWindow::ClearAndHide()
|
|||||||
pParent->GrabFocus();
|
pParent->GrabFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CodeCompleteWindow::SetVisibleEntries()
|
||||||
|
{
|
||||||
|
pListBox->SetVisibleEntries();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace basctl
|
} // namespace basctl
|
||||||
|
|
||||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user