Changeset 1488

Show
Ignore:
Timestamp:
07/11/08 08:03:25 (2 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

Location:
trunk/peppy
Files:
4 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) 
  • trunk/peppy/frame.py

    r1487 r1488  
    7777 
    7878class MyNotebook(wx.aui.AuiNotebook, debugmixin): 
    79     debuglevel = 1 
    8079     
    8180    def __init__(self, parent, size=wx.DefaultSize): 
     
    325324 
    326325class BufferFrame(wx.Frame, ClassPrefs, debugmixin): 
    327     debuglevel = 1 
    328326    frameid=0 
    329327    load_error_count = 0 
  • trunk/peppy/main.py

    r1487 r1488  
    2828from peppy.lib.textutil import piglatin 
    2929 
    30 OrigCallAfter = wx.CallAfter 
    31 def NewCallAfter(*args, **kwargs): 
    32     dprint("CallAfter: args=%s kwargs=%s" % (str(args), str(kwargs))) 
    33     OrigCallAfter(*args, **kwargs) 
    34     #wx.GetApp().cooperativeYield() 
    35 wx.CallAfter = NewCallAfter 
     30# Debug method to display when CallAfters are being made. 
     31#OrigCallAfter = wx.CallAfter 
     32#def NewCallAfter(*args, **kwargs): 
     33#    dprint("CallAfter: args=%s kwargs=%s" % (str(args), str(kwargs))) 
     34#    OrigCallAfter(*args, **kwargs) 
     35#    #wx.GetApp().cooperativeYield() 
     36#wx.CallAfter = NewCallAfter 
    3637 
    3738#### py2exe support 
     
    10061007        # Gnome filemanager puts '//' at the beginning of absolute pathnames 
    10071008        sys.argv = [arg[1:] if arg.startswith("//") else arg for arg in sys.argv] 
    1008         dprint(sys.argv) 
     1009        #dprint(sys.argv) 
    10091010     
    10101011    peppy = Peppy(redirect=False) 
  • trunk/peppy/major.py

    r1487 r1488  
    222222            self.minibuffer = None 
    223223            self.Layout() 
    224             dprint("active major mode = %s, trying to remove minibuffer from %s" % (self.editwin.frame.getActiveMajorMode(), self.editwin)) 
     224            #dprint("active major mode = %s, trying to remove minibuffer from %s" % (self.editwin.frame.getActiveMajorMode(), self.editwin)) 
    225225            if self.editwin.frame.getActiveMajorMode() == self.editwin: 
    226226                self.editwin.focus() 
    227             else: 
    228                 dprint("active major mode = %s, tried to remove minibuffer from %s" % (self.editwin.frame.getActiveMajorMode(), self.editwin)) 
     227            #else: 
     228                #dprint("active major mode = %s, tried to remove minibuffer from %s" % (self.editwin.frame.getActiveMajorMode(), self.editwin)) 
    229229 
    230230