include/sfx2/templatedlg.hxx    |    1 +
 sfx2/source/doc/templatedlg.cxx |   21 +++++++++++++++++++++
 2 files changed, 22 insertions(+)

New commits:
commit 86519381cd6c7df26087461680f5467aacdc89fc
Author: Tibor Móger <hapcy...@gmail.com>
Date:   Wed Dec 7 15:41:57 2016 +0100

    tdf#94576 handle esc keypress on templatemanagerdialog
    
    SfxTemplateManagerDlg now overrides behaviour of ModalDialog on
    EventNotify by checking if the pressed key was esc and
    the searchFilter is not empty and it was focused. In this case
    instead of letting ModalDialog close the modal
    it clears the searchFilter
    
    Change-Id: I90d91a3b152f68b6c8780963d1b95258d9ccf23a
    Reviewed-on: https://gerrit.libreoffice.org/31736
    Reviewed-by: Tamás Zolnai <tamas.zol...@collabora.com>
    Tested-by: Tamás Zolnai <tamas.zol...@collabora.com>

diff --git a/include/sfx2/templatedlg.hxx b/include/sfx2/templatedlg.hxx
index ecf75d6..c130257 100644
--- a/include/sfx2/templatedlg.hxx
+++ b/include/sfx2/templatedlg.hxx
@@ -49,6 +49,7 @@ public:
     virtual ~SfxTemplateManagerDlg() override;
     virtual void dispose() override;
     virtual short Execute() override;
+    virtual bool EventNotify( NotifyEvent& rNEvt ) override;
 
     void setDocumentModel (const css::uno::Reference<css::frame::XModel> 
&rModel);
 
diff --git a/sfx2/source/doc/templatedlg.cxx b/sfx2/source/doc/templatedlg.cxx
index 114c6a7..63056eb 100644
--- a/sfx2/source/doc/templatedlg.cxx
+++ b/sfx2/source/doc/templatedlg.cxx
@@ -299,6 +299,27 @@ short SfxTemplateManagerDlg::Execute()
     return ModalDialog::Execute();
 }
 
+bool SfxTemplateManagerDlg::EventNotify( NotifyEvent& rNEvt )
+{
+    if (mpSearchFilter != nullptr &&
+        mpSearchFilter->HasControlFocus() &&
+        !mpSearchFilter->GetText().isEmpty() &&
+        rNEvt.GetType() == MouseNotifyEvent::KEYINPUT)
+    {
+        const KeyEvent* pKEvt    = rNEvt.GetKeyEvent();
+        vcl::KeyCode    aKeyCode = pKEvt->GetKeyCode();
+        sal_uInt16      nKeyCode = aKeyCode.GetCode();
+
+        if ( nKeyCode == KEY_ESCAPE )
+        {
+            mpSearchFilter->SetText("");
+            mpSearchFilter->UpdateData();
+            return true;
+        }
+    }
+    return ModalDialog::EventNotify(rNEvt);
+}
+
 void SfxTemplateManagerDlg::setDocumentModel(const 
uno::Reference<frame::XModel> &rModel)
 {
     m_xModel = rModel;
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to