Author: bugman
Date: Wed Oct 15 19:32:18 2014
New Revision: 26293

URL: http://svn.gna.org/viewcvs/relax?rev=26293&view=rev
Log:
Modified the behaviour of the relax controller window so that pressing escape 
closes the window.

This involves setting the initial focus on the LogCtrl, and catching the ESC 
key press in the
LogCtrl as well as all relax controller read only wx.Field elements and calling 
the parent
controller handle_close() method.


Modified:
    trunk/gui/controller.py

Modified: trunk/gui/controller.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/gui/controller.py?rev=26293&r1=26292&r2=26293&view=diff
==============================================================================
--- trunk/gui/controller.py     (original)
+++ trunk/gui/controller.py     Wed Oct 15 19:32:18 2014
@@ -125,6 +125,9 @@
             info = Info_box()
             print(info.intro_text())
 
+        # Set the focus on the log control.
+        self.log_panel.SetFocus()
+
         # Register functions with the observer objects.
         status.observers.pipe_alteration.register('controller', 
self.update_controller, method_name='update_controller')
         status.observers.auto_analyses.register('controller', 
self.update_controller, method_name='update_controller')
@@ -234,6 +237,9 @@
             text.SetToolTipString(tooltip)
             field.SetToolTipString(tooltip)
 
+        # Handle key events.
+        field.Bind(wx.EVT_KEY_DOWN, self.handler_key_down)
+
         # Return the control.
         return field
 
@@ -312,6 +318,18 @@
 
         # Close the window.
         self.Hide()
+
+
+    def handler_key_down(self, event=None):
+        """Event handler for key strokes.
+
+        @keyword event: The wx event.
+        @type event:    wx event
+        """
+
+        # Use ESC to close the window.
+        if event.GetKeyCode() == 27:
+            self.handler_close(event)
 
 
     def handler_timer(self, event):
@@ -715,6 +733,10 @@
         elif event.ControlDown() and event.GetKeyCode() == 312:
             self.on_goto_end(event)
 
+        # Use ESC to close the window.
+        if event.GetKeyCode() == 27:
+            self.controller.handler_close(event)
+
 
     def capture_mouse(self, event):
         """Control the mouse events.


_______________________________________________
relax (http://www.nmr-relax.com)

This is the relax-commits mailing list
[email protected]

To unsubscribe from this list, get a password
reminder, or change your subscription options,
visit the list information page at
https://mail.gna.org/listinfo/relax-commits

Reply via email to