Changeset 1004 for trunk/GSASIIplot.py


Ignore:
Timestamp:
Jul 21, 2013 8:38:32 PM (10 years ago)
Author:
toby
Message:

recapture focus on plot window so keyboard commands work

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/GSASIIplot.py

    r998 r1004  
    122122        self.status.SetStatusWidths([150,-1])
    123123        self.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CHANGED, self.OnPageChanged)
     124        self.nb.Bind(wx.EVT_KEY_UP,self.OnNotebookKey)
    124125       
    125126        self.plotList = []
    126127           
     128    def OnNotebookKey(self,event):
     129        '''Called when a keystroke event gets picked up by the notebook window
     130        rather the child. This is not expected, but somehow it does sometimes
     131        on the Mac and perhaps Linux.
     132
     133        Assume that the page associated with the currently displayed tab
     134        has a child, .canvas; give that child the focus and pass it the event.
     135        '''
     136        Page = self.nb.GetPage(self.nb.GetSelection())
     137        try:
     138            Page.canvas.SetFocus()
     139            wx.PostEvent(Page.canvas,event)
     140        except AttributeError:
     141            pass
     142
    127143    def addMpl(self,name=""):
    128144        'Add a tabbed page with a matplotlib plot'
     
    10101026            cb.SetValue(' key press')
    10111027            wx.CallAfter(OnPlotKeyPress,event)
     1028        try:
     1029            Page.canvas.SetFocus() # redirect the Focus from the button back to the plot
     1030        except:
     1031            pass
     1032
    10121033                       
    10131034    def OnMotion(event):
     
    21272148            if event.key in 'l':
    21282149                wx.CallAfter(OnImPlotKeyPress,event)
     2150        try:
     2151            Page.canvas.SetFocus() # redirect the Focus from the button back to the plot
     2152        except:
     2153            pass
    21292154                       
    21302155    def OnImPick(event):
     
    27252750            cb.SetValue(' save as/key:')
    27262751            wx.CallAfter(OnKey,event)
     2752        try:
     2753            Page.canvas.SetFocus() # redirect the Focus from the button back to the plot
     2754        except:
     2755            pass
    27272756
    27282757    def OnKey(event):           #on key UP!!
Note: See TracChangeset for help on using the changeset viewer.