Skip to content

Commit

Permalink
Add middle click to close fit (#608)
Browse files Browse the repository at this point in the history
  • Loading branch information
blitzmann committed May 15, 2016
1 parent 80dab63 commit 51fbcce
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions gui/chromeTabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,7 @@ def __init__(self, parent, pos=(0, 0), size=(100, 22), id=wx.ID_ANY, canAdd=True
self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnErase)
self.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
self.Bind(wx.EVT_LEFT_UP, self.OnLeftUp)
self.Bind(wx.EVT_MIDDLE_UP, self.OnMiddleUp)
self.Bind(wx.EVT_MOTION, self.OnMotion)
self.Bind(wx.EVT_SIZE, self.OnSize)
self.Bind(wx.EVT_SYS_COLOUR_CHANGED, self.OnSysColourChanged)
Expand Down Expand Up @@ -796,6 +797,28 @@ def OnLeftUp(self, event):
if self.CheckTabClose(tab, mposx, mposy):
return

def OnMiddleUp(self, event):
mposx, mposy = event.GetPosition()

tab = self.FindTabAtPos(mposx, mposy)

if tab is None or not tab.closeButton: # if not able to close, return False
return False

index = self.tabs.index(tab)
ev = PageClosing(index)
wx.PostEvent(self.Parent, ev)
if ev.isVetoed():
return False

index = self.GetTabIndex(tab)
self.DeleteTab(index)
wx.PostEvent(self.Parent, PageClosed(index=index))
sel = self.GetSelected()

if sel is not None:
wx.PostEvent(self.Parent, PageChanged(-1, sel))

def GetSelectedTab(self):
for tab in self.tabs:
if tab.GetSelected():
Expand Down

0 comments on commit 51fbcce

Please sign in to comment.