Author: bugman
Date: Thu Oct 16 18:31:34 2014
New Revision: 26303

URL: http://svn.gna.org/viewcvs/relax?rev=26303&view=rev
Log:
Merged revisions 26293-26296 via svnmerge from 
svn+ssh://[email protected]/svn/relax/trunk

........
  r26293 | bugman | 2014-10-15 19:32:18 +0200 (Wed, 15 Oct 2014) | 7 lines
  
  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.
........
  r26294 | bugman | 2014-10-15 23:57:44 +0200 (Wed, 15 Oct 2014) | 5 lines
  
  Replaced the hardcoded integer keycodes in the relax controller with the wx 
variables.
  
  This is for the LogCtrl.capture_keys() handler method for dealing with key 
presses.
........
  r26295 | bugman | 2014-10-16 10:46:02 +0200 (Thu, 16 Oct 2014) | 8 lines
  
  Improvement for all wizards and user functions in the relax GUI.
  
  The focus is now set on the currently displayed page of the wizard.  This 
allows the keyboard to be
  active without requiring a mouse click.  Now text can be instantly input into 
the first text control
  and the tab key can jump between elements.  As the GUI user functions are 
wizards with a single
  page, this is a significant usability improvement for the GUI.
........
  r26296 | bugman | 2014-10-16 10:49:18 +0200 (Thu, 16 Oct 2014) | 7 lines
  
  The ESC character now closes all wizards and user functions in the relax GUI.
  
  By using an accelerator table set to the entire wizard window to catch the 
ESC keyboard event, the
  ESC key will cause the _handler_escape() method to be called which then calls 
the windows Close()
  method to close the window.
........

Modified:
    branches/space_mapping_refactor/   (props changed)
    branches/space_mapping_refactor/gui/controller.py
    branches/space_mapping_refactor/gui/wizards/wiz_objects.py

Propchange: branches/space_mapping_refactor/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Thu Oct 16 18:31:34 2014
@@ -1 +1 @@
-/trunk:1-26279,26283-26292
+/trunk:1-26302

Modified: branches/space_mapping_refactor/gui/controller.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/space_mapping_refactor/gui/controller.py?rev=26303&r1=26302&r2=26303&view=diff
==============================================================================
--- branches/space_mapping_refactor/gui/controller.py   (original)
+++ branches/space_mapping_refactor/gui/controller.py   Thu Oct 16 18:31:34 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() == wx.WXK_ESCAPE:
+            self.handler_close(event)
 
 
     def handler_timer(self, event):
@@ -688,16 +706,16 @@
         # Find next (Ctrl-G on Mac OS X, F3 on all others).
         if 'darwin' in sys.platform and event.ControlDown() and 
event.GetKeyCode() == 71:
             self.find_next(event)
-        elif 'darwin' not in sys.platform and event.GetKeyCode() == 342:
+        elif 'darwin' not in sys.platform and event.GetKeyCode() == wx.WXK_F3:
             self.find_next(event)
 
         # Allow caret movements (arrow keys, home, end).
-        if event.GetKeyCode() in [312, 313, 314, 315, 316, 317]:
+        if event.GetKeyCode() in [wx.WXK_END, wx.WXK_HOME, wx.WXK_LEFT, 
wx.WXK_UP, wx.WXK_RIGHT, wx.WXK_DOWN]:
             self.at_end = False
             event.Skip()
 
         # Allow scrolling (pg up, pg dn):
-        if event.GetKeyCode() in [366, 367]:
+        if event.GetKeyCode() in [wx.WXK_PAGEUP, wx.WXK_PAGEDOWN]:
             self.at_end = False
             event.Skip()
 
@@ -710,10 +728,14 @@
             self.on_zoom_in(event)
 
         # Jump to start or end (Ctrl-Home and Ctrl-End).
-        if event.ControlDown() and event.GetKeyCode() == 313:
+        if event.ControlDown() and event.GetKeyCode() == wx.WXK_HOME:
             self.on_goto_start(event)
-        elif event.ControlDown() and event.GetKeyCode() == 312:
+        elif event.ControlDown() and event.GetKeyCode() == wx.WXK_END:
             self.on_goto_end(event)
+
+        # Use ESC to close the window.
+        if event.GetKeyCode() == wx.WXK_ESCAPE:
+            self.controller.handler_close(event)
 
 
     def capture_mouse(self, event):

Modified: branches/space_mapping_refactor/gui/wizards/wiz_objects.py
URL: 
http://svn.gna.org/viewcvs/relax/branches/space_mapping_refactor/gui/wizards/wiz_objects.py?rev=26303&r1=26302&r2=26303&view=diff
==============================================================================
--- branches/space_mapping_refactor/gui/wizards/wiz_objects.py  (original)
+++ branches/space_mapping_refactor/gui/wizards/wiz_objects.py  Thu Oct 16 
18:31:34 2014
@@ -481,6 +481,13 @@
         # Bind some events.
         self.Bind(wx.EVT_CLOSE, self._handler_close)
 
+        # ESC to exit, via an accelerator table which creates menu events.
+        id = wx.NewId()
+        self.acc_list = [(wx.ACCEL_NORMAL, wx.WXK_ESCAPE, id)]
+        self.acc_table = wx.AcceleratorTable(self.acc_list)
+        self.SetAcceleratorTable(self.acc_table)
+        self.Bind(wx.EVT_MENU, self._handler_escape, id=self.acc_list[0][2])
+
 
     def _apply(self, event=None):
         """Execute the current page's 'Apply' method.
@@ -635,6 +642,9 @@
         # Execute the page's on_init() method.
         self._pages[i].on_init()
 
+        # Set the focus to this page to allow the keyboard to be functional 
without a mouse click.
+        self._pages[i].SetFocus()
+
 
     def _go_back(self, event=None):
         """Return to the previous page.
@@ -713,6 +723,17 @@
 
         # Continue with the window closing.
         event.Skip()
+
+
+    def _handler_escape(self, event=None):
+        """Event handler for key strokes.
+
+        @keyword event: The wx event.
+        @type event:    wx event
+        """
+
+        # Close the window.
+        self.Close()
 
 
     def _next_fn(self):


_______________________________________________
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