summaryrefslogtreecommitdiff
path: root/fpicker
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2022-04-14 12:05:49 +0100
committerCaolán McNamara <caolanm@redhat.com>2022-04-14 16:10:37 +0200
commit3f793465819f63aa001f5842f232be24d13153fd (patch)
treec24b161f0e30cfef7f1850ae382e640661a317a1 /fpicker
parentae0e7e3918284c31a91acca0f733919926ae3a62 (diff)
tdf#148101 don't autocomplete remote files dialog entry on delete/backspace
Change-Id: Ieddb41eb37e7090416a418afeffb76ce0eddf90a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133009 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'fpicker')
-rw-r--r--fpicker/source/office/autocmpledit.cxx25
-rw-r--r--fpicker/source/office/autocmpledit.hxx2
2 files changed, 26 insertions, 1 deletions
diff --git a/fpicker/source/office/autocmpledit.cxx b/fpicker/source/office/autocmpledit.cxx
index 5a31c7bdc501..89a2d0b0c245 100644
--- a/fpicker/source/office/autocmpledit.cxx
+++ b/fpicker/source/office/autocmpledit.cxx
@@ -7,21 +7,44 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
+#include <vcl/event.hxx>
#include "autocmpledit.hxx"
AutocompleteEdit::AutocompleteEdit(std::unique_ptr<weld::Entry> xEntry)
: m_xEntry(std::move(xEntry))
, m_aChangedIdle("fpicker::AutocompleteEdit m_aChangedIdle")
+ , m_nLastCharCode(0)
{
m_xEntry->connect_changed(LINK(this, AutocompleteEdit, ChangedHdl));
+ m_xEntry->connect_key_press(LINK(this, AutocompleteEdit, KeyInputHdl));
m_aChangedIdle.SetInvokeHandler(LINK(this, AutocompleteEdit, TryAutoComplete));
}
+IMPL_LINK(AutocompleteEdit, KeyInputHdl, const KeyEvent&, rKEvt, bool)
+{
+ m_nLastCharCode = rKEvt.GetKeyCode().GetCode();
+ return false;
+}
+
IMPL_LINK_NOARG(AutocompleteEdit, ChangedHdl, weld::Entry&, void)
{
m_aChangeHdl.Call(*m_xEntry);
- m_aChangedIdle.Start(); //launch this to happen on idle after cursor position will have been set
+
+ switch (m_nLastCharCode)
+ {
+ case css::awt::Key::DELETE_WORD_BACKWARD:
+ case css::awt::Key::DELETE_WORD_FORWARD:
+ case css::awt::Key::DELETE_TO_BEGIN_OF_LINE:
+ case css::awt::Key::DELETE_TO_END_OF_LINE:
+ case KEY_BACKSPACE:
+ case KEY_DELETE:
+ m_aChangedIdle.Stop();
+ break;
+ default:
+ m_aChangedIdle.Start(); //launch this to happen on idle after cursor position will have been set
+ break;
+ }
}
void AutocompleteEdit::AddEntry( const OUString& rEntry )
diff --git a/fpicker/source/office/autocmpledit.hxx b/fpicker/source/office/autocmpledit.hxx
index bfb2ee096a63..3eb79eb14aa6 100644
--- a/fpicker/source/office/autocmpledit.hxx
+++ b/fpicker/source/office/autocmpledit.hxx
@@ -22,7 +22,9 @@ private:
std::vector<OUString> m_aMatching;
Idle m_aChangedIdle;
Link<weld::Entry&, void> m_aChangeHdl;
+ sal_uInt16 m_nLastCharCode;
+ DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
DECL_LINK(ChangedHdl, weld::Entry&, void);
DECL_LINK(TryAutoComplete, Timer*, void);