Show
Ignore:
Timestamp:
07/11/08 08:03:25 (4 months ago)
Author:
rob
Message:

Fixed the bad SetFocus? call by placing both the removeFromParent and performAction methods in CallAfters?
* added the performAction method to call the action's processMinibuffer

Files:
1 modified

Legend:

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

    r1487 r1488  
    185185        if self.mode: 
    186186            wx.CallAfter(self.mode.removeMinibuffer, self) 
    187          
     187     
     188    def performAction(self, value): 
     189        """Execute the processMinibuffer method of the action""" 
     190        error = self.action.processMinibuffer(self, self.mode, value) 
     191        if error is not None: 
     192            self.mode.frame.SetStatusText(error) 
    188193 
    189194 
     
    235240            self.finish_callback() 
    236241        else: 
    237             self.mode.removeMinibuffer(detach_only=True) 
     242            # Remove the minibuffer and perform the action in CallAfters so 
     243            # the tab focus doesn't get confused.  If you try to perform these 
     244            # 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. 
     247            wx.CallAfter(self.removeFromParent) 
    238248            if text is not None: 
    239                 error = self.action.processMinibuffer(self, self.mode, text) 
    240                 if error is not None: 
    241                     self.mode.frame.SetStatusText(error) 
    242             self.close() 
    243             #self.removeFromParent() 
     249                wx.CallAfter(self.performAction, text) 
     250         
    244251 
    245252class IntMinibuffer(TextMinibuffer): 
     
    390397        #self.text.SetInsertionPointEnd() 
    391398 
     399        # FIXME: Using the EVT_SET_FOCUS doesn't seem to work to set the cursor 
     400        # to the end of the text.  It doesn't seem to get called at all, so 
     401        # the only way to do it appears to be to co-opt the Panel's SetFocus 
     402        # method 
    392403        self.win.saveSetFocus = self.win.SetFocus 
    393404        self.win.SetFocus = self.SetFocus 
    394405         
    395406    def SetFocus(self): 
    396         dprint(self) 
     407        #dprint(self) 
    397408        self.win.saveSetFocus() 
    398409        self.text.SetInsertionPointEnd() 
    399410     
    400411    def OnFocus(self, evt): 
    401         dprint() 
     412        #dprint() 
    402413        self.text.SetInsertionPointEnd() 
    403414 
     
    486497                return 
    487498         
    488         error = self.action.processMinibuffer(self, self.mode, results) 
    489         if error is not None: 
    490             self.mode.frame.SetStatusText(error) 
    491         self.removeFromParent() 
     499        wx.CallAfter(self.removeFromParent) 
     500        wx.CallAfter(self.performAction, results)