14 : m_xEntry(
std::move(xEntry))
15 , m_aChangedIdle(
"fpicker::AutocompleteEdit m_aChangedIdle")
26 m_nLastCharCode = rKEvt.GetKeyCode().GetCode();
32 m_aChangeHdl.Call(*m_xEntry);
34 switch (m_nLastCharCode)
36 case css::awt::Key::DELETE_WORD_BACKWARD:
37 case css::awt::Key::DELETE_WORD_FORWARD:
38 case css::awt::Key::DELETE_TO_BEGIN_OF_LINE:
39 case css::awt::Key::DELETE_TO_END_OF_LINE:
42 m_aChangedIdle.Stop();
45 m_aChangedIdle.Start();
63 OUString aCurText = m_xEntry->get_text();
65 int nStartPos, nEndPos;
66 m_xEntry->get_selection_bounds(nStartPos, nEndPos);
67 if (std::max(nStartPos, nEndPos) != aCurText.getLength())
70 auto nLen = std::min(nStartPos, nEndPos);
71 aCurText = aCurText.copy( 0, nLen );
72 if( aCurText.isEmpty() )
75 if( !m_aEntries.empty() )
77 if( Match( aCurText ) )
79 m_xEntry->set_text(m_aMatching[0]);
80 auto nNewLen = m_aMatching[0].getLength();
81 m_xEntry->select_region(nLen, nNewLen);
94 if( rEntry.startsWithIgnoreAsciiCase( rText ) )
IMPL_LINK(AutocompleteEdit, KeyInputHdl, const KeyEvent &, rKEvt, bool)
IMPL_LINK_NOARG(AutocompleteEdit, ChangedHdl, weld::Entry &, void)
std::vector< OUString > m_aEntries
AutocompleteEdit(std::unique_ptr< weld::Entry > xEntry)
std::unique_ptr< weld::Entry > m_xEntry
bool Match(std::u16string_view rText)
void AddEntry(const OUString &rEntry)
std::vector< OUString > m_aMatching
void SetInvokeHandler(const Link< Timer *, void > &rLink)
constexpr sal_uInt16 KEY_DELETE
constexpr sal_uInt16 KEY_BACKSPACE
#define LINK(Instance, Class, Member)