diff options
author | Gergo Mocsi <gmocsi91@gmail.com> | 2013-08-02 17:36:29 +0200 |
---|---|---|
committer | Gergo Mocsi <gmocsi91@gmail.com> | 2013-09-02 18:16:55 +0200 |
commit | 972bbede6e79fb7c828a32a560559391290af997 (patch) | |
tree | 050a136aae4e9c19b143e2d10e80cf5c2b8aa2ea /basctl | |
parent | GSOC work, show the cursor when typing 2 (diff) | |
download | core-972bbede6e79fb7c828a32a560559391290af997.tar.gz core-972bbede6e79fb7c828a32a560559391290af997.zip |
GSOC work, KeyInput instead of PreNotify
CodeCompleteListBox now uses KeyInput instead of PreNotify to handle key events.
The cursor is visible, arrow keys navigate the listbox correctly.
Change-Id: Ia0d5c5c48858d345dc4b4886ece1db618bdfc67c
Diffstat (limited to 'basctl')
-rw-r--r-- | basctl/source/basicide/baside2.hxx | 4 | ||||
-rw-r--r-- | basctl/source/basicide/baside2b.cxx | 84 |
2 files changed, 18 insertions, 70 deletions
diff --git a/basctl/source/basicide/baside2.hxx b/basctl/source/basicide/baside2.hxx index 5618f7618cc7..68f16a12216e 100644 --- a/basctl/source/basicide/baside2.hxx +++ b/basctl/source/basicide/baside2.hxx @@ -491,9 +491,7 @@ public: void InsertSelectedEntry(); //insert the selected entry DECL_LINK(ImplDoubleClickHdl, void*); - //DECL_LINK(ImplSelectionChangeHdl, void*); - - virtual long PreNotify( NotifyEvent& rNEvt ); + DECL_LINK(ImplSelectHdl, void*); protected: virtual void KeyInput( const KeyEvent& rKeyEvt ); diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx index 00b048d26cf1..fd69045302f0 100644 --- a/basctl/source/basicide/baside2b.cxx +++ b/basctl/source/basicide/baside2b.cxx @@ -508,11 +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() ) + if( pCodeCompleteWnd->IsVisible() && CodeCompleteOptions::IsCodeCompleteOn() ) { std::cerr << "EditorWindow::KeyInput" << std::endl; pCodeCompleteWnd->GetListBox()->KeyInput(rKEvt); + if( rKEvt.GetKeyCode().GetCode() == KEY_UP + || rKEvt.GetKeyCode().GetCode() == KEY_DOWN ) + return; } if( (rKEvt.GetKeyCode().GetCode() == KEY_SPACE || @@ -2552,7 +2554,7 @@ CodeCompleteListBox::CodeCompleteListBox( CodeCompleteWindow* pPar ) pCodeCompleteWindow( pPar ) { SetDoubleClickHdl(LINK(this, CodeCompleteListBox, ImplDoubleClickHdl)); - //SetSelectHdl(LINK(this, CodeCompleteListBox, ImplSelectionChangeHdl)); + SetSelectHdl(LINK(this, CodeCompleteListBox, ImplSelectHdl)); } IMPL_LINK_NOARG(CodeCompleteListBox, ImplDoubleClickHdl) @@ -2561,11 +2563,11 @@ IMPL_LINK_NOARG(CodeCompleteListBox, ImplDoubleClickHdl) return 0; } -/*IMPL_LINK_NOARG(CodeCompleteListBox, ImplSelectionChangeHdl) -{ +IMPL_LINK_NOARG(CodeCompleteListBox, ImplSelectHdl) +{//give back the focus to the parent pCodeCompleteWindow->pParent->GrabFocus(); return 0; -}*/ +} void CodeCompleteListBox::InsertSelectedEntry() { @@ -2603,65 +2605,6 @@ void CodeCompleteListBox::InsertSelectedEntry() } } -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 ) ) - { - pCodeCompleteWindow->pParent->GetEditView()->InsertText( OUString(aKeyEvt.GetCharCode()) ); - aFuncBuffer.append(aKeyEvt.GetCharCode()); - SetVisibleEntries(); - //pCodeCompleteWindow->pParent->GetEditView()->GetWindow()->GrabFocus(); - return 0; - } - else - { - switch( aChar ) - { - case KEY_ESCAPE: // hide, do nothing - pCodeCompleteWindow->ClearAndHide(); - return 0; - case KEY_TAB: case KEY_SPACE: - /* space, tab the user probably have typed in the whole - * procedure name: hide the window, and insert the tab/space - */ - pCodeCompleteWindow->pParent->GetEditView()->InsertText( OUString(aKeyEvt.GetCharCode()) ); - pCodeCompleteWindow->Hide(); - pCodeCompleteWindow->pParent->GetEditView()->SetSelection( pCodeCompleteWindow->pParent->GetEditView()->CursorEndOfLine(pCodeCompleteWindow->GetTextSelection().GetStart()) ); - pCodeCompleteWindow->pParent->GrabFocus(); - return 0; - case KEY_BACKSPACE: case KEY_DELETE: - if( aFuncBuffer.toString() != OUString("") ) - { - 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 = aFuncBuffer.remove(aFuncBuffer.getLength()-1, 1); - pCodeCompleteWindow->pParent->GetEditView()->SetSelection(TextSelection(aStart, aEnd)); - pCodeCompleteWindow->pParent->GetEditView()->DeleteSelected(); - SetVisibleEntries(); - } - else - { - pCodeCompleteWindow->ClearAndHide(); - } - return 0; - 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 ); -} - void CodeCompleteListBox::SetVisibleEntries() { for(sal_uInt16 i=0; i< GetEntryCount(); ++i) @@ -2678,11 +2621,9 @@ 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(); } @@ -2712,6 +2653,15 @@ void CodeCompleteListBox::KeyInput( const KeyEvent& rKeyEvt ) case KEY_RETURN: InsertSelectedEntry(); break; + case KEY_UP: case KEY_DOWN: + std::cerr << "up/down ke in CodeCompleteListBox::KeyInput" << std::endl; + //GrabFocus(); + NotifyEvent nEvt( EVENT_KEYINPUT, NULL, &rKeyEvt ); + PreNotify(nEvt); + //pCodeCompleteWindow->pParent->GrabFocus(); + //SetVisibleEntries(); + //pCodeCompleteWindow->pParent->GrabFocus(); + break; } } ListBox::KeyInput(rKeyEvt); |