Changeset 1489

Show
Ignore:
Timestamp:
07/11/08 19:36:22 (8 weeks ago)
Author:
rob
Message:

Found out where the SetFocus? events were getting called: from within the TextCtrlAutoComplete?.
* made new callback method setFocusCallback to make sure the control hasn't been removed before setting focus

Location:
trunk/peppy
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/peppy/actions/minibuffer.py

    r1488 r1489  
    174174        self.panel = None 
    175175 
    176     def removeFromParent(self): 
     176    def removeFromParent(self, call_after=False): 
    177177        """ 
    178178        Convenience routine to destroy minibuffer after the event loop 
     
    184184        # remove the minibuffer if the mode is still valid. 
    185185        if self.mode: 
    186             wx.CallAfter(self.mode.removeMinibuffer, self) 
     186            if call_after: 
     187                wx.CallAfter(self.mode.removeMinibuffer, self) 
     188            else: 
     189                self.mode.removeMinibuffer(self) 
    187190     
    188191    def performAction(self, value): 
     
    243246            # the tab focus doesn't get confused.  If you try to perform these 
    244247            # actions directly, the focus will return to the original tab if 
    245             # the action causes a new tab to be created.  Moving everything to 
    246             # CallAfters prevents this. 
     248            # the action causes a new tab to be created.  Moving everything 
     249            # to CallAfters prevents this.  Also, MSW can crash if performing 
     250            # these directly, so it's worth the extra milliseconds to use 
     251            # CallAfter 
    247252            wx.CallAfter(self.removeFromParent) 
    248253            if text is not None: 
    249254                wx.CallAfter(self.performAction, text) 
    250          
     255 
    251256 
    252257class IntMinibuffer(TextMinibuffer): 
  • trunk/peppy/lib/textctrl_autocomplete.py

    r1474 r1489  
    380380        if ( self.GetInsertionPoint() == self._lastinsertionpoint ) : 
    381381            self._showDropDown ( not self.dropdown.IsShown() ) 
    382         wx.CallAfter(self.SetFocus) 
     382        wx.CallAfter(self.setFocusCallback) 
    383383        event.Skip () 
     384     
     385    def setFocusCallback(self, end=False): 
     386        """Callback for use within wx.CallAfter to prevent focus being set 
     387        after the control has been removed. 
     388        """ 
     389        #print("Here in setFocusCallback") 
     390        if self: 
     391            #print("setting focus") 
     392            self.SetFocus() 
     393            if end: 
     394                self.SetInsertionPointEnd() 
    384395     
    385396    def OnSetFocus(self, evt): 
     
    392403        #print("changed=%s other=%s" % (changed, other)) 
    393404        if self._mac: 
    394             wx.CallAfter(self.SetFocus) 
    395             wx.CallAfter(self.SetInsertionPointEnd) 
     405            wx.CallAfter(self.setFocusCallback, True) 
    396406            event.Skip() 
    397407            return 
     
    470480                self.dropdown . SetPosition ( wx.Point(x, y - height - size.GetHeight()) ) 
    471481        self.dropdown.Show ( show ) 
    472         wx.CallAfter(self.SetFocus) 
     482        wx.CallAfter(self.setFocusCallback) 
    473483 
    474484    def _listItemVisible( self ) :