MCPcopy Index your code
hub / github.com/pyfa-org/Pyfa / CheckTabClose

Method CheckTabClose

gui/chrome_tabs.py:998–1027  ·  view source on GitHub ↗

Determines if close button was selected for the given tab by comparing x and y position with known close button region

(self, tab, x, y)

Source from the content-addressed store, hash-verified

996 return False
997
998 def CheckTabClose(self, tab, x, y):
999 """
1000 Determines if close button was selected for the given tab by comparing
1001 x and y position with known close button region
1002 """
1003 if not tab.closeable: # if not able to close, return False
1004 return False
1005
1006 region = tab.GetCloseButtonRegion()
1007 posx, posy = tab.GetPosition()
1008 region.Offset(round(posx), round(posy))
1009
1010 if region.Contains(x, y):
1011 index = self.tabs.index(tab)
1012 ev = PageClosing(index)
1013 wx.PostEvent(self.Parent, ev)
1014
1015 if ev.isVetoed():
1016 return False
1017
1018 index = self.GetTabIndex(tab)
1019 self.Parent.DeletePage(index)
1020 wx.PostEvent(self.Parent, PageClosed(index=index))
1021
1022 sel = self.GetSelected()
1023 if sel is not None:
1024 wx.PostEvent(self.Parent, PageChanged(-1, sel))
1025
1026 return True
1027 return False
1028
1029 def CheckAddButton(self, x, y):
1030 """

Callers 1

OnLeftUpMethod · 0.95

Calls 8

GetTabIndexMethod · 0.95
GetSelectedMethod · 0.95
PageClosingClass · 0.85
PageChangedClass · 0.85
GetCloseButtonRegionMethod · 0.80
isVetoedMethod · 0.80
GetPositionMethod · 0.45
DeletePageMethod · 0.45

Tested by

no test coverage detected