Changeset 39b7019 in sasview for sansview/perspectives


Ignore:
Timestamp:
Sep 26, 2009 9:11:12 AM (15 years ago)
Author:
Mathieu Doucet <doucetm@…>
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
beaaa8b
Parents:
8eeb0b6
Message:

sansview: fix highlighting for sansview text controls

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sansview/perspectives/fitting/basepage.py

    r6e9150d r39b7019  
    140140            @param text_enter_callback: callback method for EVT_TEXT_ENTER event 
    141141        """ 
     142        ## Set to True when the mouse is clicked while the whole string is selected 
     143        full_selection = False 
     144        ## Call back for EVT_SET_FOCUS events 
     145        _on_set_focus_callback = None 
     146         
    142147        def __init__(self, parent, id=-1, value=wx.EmptyString, pos=wx.DefaultPosition,  
    143148                     size=wx.DefaultSize, style=0, validator=wx.DefaultValidator, name=wx.TextCtrlNameStr, 
     
    148153             
    149154            # Bind appropriate events 
    150             self.Bind(wx.EVT_SET_FOCUS,  parent.onSetFocus \ 
    151                       if set_focus_callback is None else set_focus_callback) 
     155            self._on_set_focus_callback = parent.onSetFocus \ 
     156                      if set_focus_callback is None else set_focus_callback 
     157            self.Bind(wx.EVT_SET_FOCUS, self._on_set_focus) 
    152158            self.Bind(wx.EVT_KILL_FOCUS, parent._onparamEnter \ 
    153159                      if kill_focus_callback is None else kill_focus_callback) 
    154160            self.Bind(wx.EVT_TEXT_ENTER, parent._onparamEnter \ 
    155161                      if text_enter_callback is None else text_enter_callback) 
    156             self.Bind(wx.EVT_LEFT_UP,    parent._highlight_text \ 
     162            self.Bind(wx.EVT_LEFT_UP,    self._highlight_text \ 
    157163                      if mouse_up_callback is None else mouse_up_callback) 
     164             
     165        def _on_set_focus(self, event): 
     166            """ 
     167                Catch when the text control is set in focus to highlight the whole 
     168                text if necessary 
     169                @param event: mouse event 
     170            """ 
     171            event.Skip() 
     172            self.full_selection = True 
     173            return self._on_set_focus_callback(event) 
     174         
     175        def _highlight_text(self, event): 
     176            """ 
     177                Highlight text of a TextCtrl only of no text has be selected 
     178                @param event: mouse event 
     179            """ 
     180            # Make sure the mouse event is available to other listeners 
     181            event.Skip() 
     182            control  = event.GetEventObject() 
     183            if self.full_selection: 
     184                self.full_selection = False 
     185                # Check that we have a TextCtrl 
     186                if issubclass(control.__class__, wx.TextCtrl): 
     187                    # Check whether text has been selected,  
     188                    # if not, select the whole string 
     189                    (start, end) = control.GetSelection() 
     190                    if start==end: 
     191                        control.SetSelection(-1,-1) 
     192                     
    158193        
    159194    def onContextMenu(self, event):  
     
    479514            after fitting 
    480515        """ 
    481          
    482516        if hasattr(self,"text2_3"): 
    483517            self.text2_3.Hide() 
     
    503537        return 
    504538     
    505     def _highlight_text(self, event): 
    506         """ 
    507             Highlight text of a TextCtrl only of no text has be selected 
    508             @param event: mouse event 
    509         """ 
    510         control  = event.GetEventObject() 
    511         # Check that we have a TextCtrl 
    512         if issubclass(control.__class__, wx.TextCtrl): 
    513             # Check whether text has been selected,  
    514             # if not, select the whole string 
    515  
    516             (start, end) = control.GetSelection() 
    517             if start==end: 
    518                 control.SetSelection(-1,-1) 
    519                  
    520         # Make sure the mouse event is available to other listeners 
    521         event.Skip() 
    522  
    523539     
    524540    def read_file(self, path): 
Note: See TracChangeset for help on using the changeset viewer.