Permalink
Browse files

Fixed bug that prevented dlgs from return focus to app

  • Loading branch information...
1 parent 58aa1da commit a27a03d53297316404c58f37e9d70d95e0767512 Alexander Stigsen committed Jul 20, 2010
Showing with 72 additions and 3 deletions.
  1. +1 −2 src/EditorCtrl.cpp
  2. +67 −0 src/WindowEnabler.h
  3. +4 −1 src/eApp.cpp
View
@@ -1558,7 +1558,6 @@ void EditorCtrl::DoAction(const tmAction& action, const map<wxString, wxString>*
}
if (m_activeTooltip) m_activeTooltip->Close();
- wxWindowDisabler wd;
// Get Action contents
const vector<char>& cmdContent = m_syntaxHandler.GetActionContent(action);
@@ -1706,7 +1705,7 @@ void EditorCtrl::DoAction(const tmAction& action, const map<wxString, wxString>*
vector<char> errout;
int pid;
{
- wxBusyCursor wait; // Show busy cursor while running command.
+ wxWindowDisabler wd;
pid = ShellRunner::RawShell(cmdContent, input, &output, &errout, env, action.isUnix, cwd);
}
View
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ *
+ * Copyright (C) 2009, Alexander Stigsen, e-texteditor.com
+ *
+ * This software is licensed under the Open Company License as described
+ * in the file license.txt, which you should have received as part of this
+ * distribution. The terms are also available at http://opencompany.org/license.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ******************************************************************************/
+
+#ifndef __WINDOWENABLER_H__
+#define __WINDOWENABLER_H__
+
+#include "wx/wxprec.h"
+#ifndef WX_PRECOMP
+#include <wx/wx.h>
+#endif
+
+class WindowEnabler
+{
+public:
+ WindowEnabler() {
+ // remember the top level windows which were already enabled, so that we
+ // don't disable them later
+ m_winDisabled = NULL;
+
+ wxWindowList::compatibility_iterator node;
+ for ( node = wxTopLevelWindows.GetFirst(); node; node = node->GetNext() ) {
+ wxWindow *winTop = node->GetData();
+
+ // we don't need to enable already enabled windows
+ if (!winTop->Enable()) {
+ if ( !m_winDisabled )
+ {
+ m_winDisabled = new wxWindowList;
+ }
+
+ m_winDisabled->Append(winTop);
+ }
+ }
+ };
+ ~WindowEnabler() {
+ wxWindowList::compatibility_iterator node;
+ for ( node = wxTopLevelWindows.GetFirst(); node; node = node->GetNext() )
+ {
+ wxWindow *winTop = node->GetData();
+ if ( !m_winDisabled || !m_winDisabled->Find(winTop) )
+ {
+ winTop->Disable();
+ }
+ //else: had been already enabled, don't disable
+ }
+
+ delete m_winDisabled;
+ };
+
+private:
+ wxWindowList *m_winDisabled;
+
+ DECLARE_NO_COPY_CLASS(WindowEnabler)
+};
+
+#endif //__WINDOWENABLER_H__
+
View
@@ -39,6 +39,7 @@
#include "IConnection.h"
#include "eIpcThread.h"
#include "hessian_ipc/hessian_values.h"
+#include "WindowEnabler.h"
#ifdef __WXMSW__
#include <wx/msw/registry.h>
@@ -1035,7 +1036,9 @@ void eApp::IpcEditorPrompt(IConnection& conn) {
const wxString title(t.c_str(), wxConvUTF8, t.size());
// Show Prompt
- const wxString text = wxGetTextFromUser(title);
+ WindowEnabler we; // otherwise dlg wont be able to return focus
+ const wxString text = wxGetTextFromUser(title, _("Input text"), wxEmptyString, editor);
+
const wxCharBuffer str = text.ToUTF8();
hessian_ipc::Writer& writer = conn.get_reply_writer();

0 comments on commit a27a03d

Please sign in to comment.