Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def onIconBoxRightClick(self, event, p=None):
"""Handle a right click in any outline widget."""
if self.busy:
return
c = self.c
g.doHook("iconrclick1", c=c, p=p, event=event)
g.doHook("iconrclick2", c=c, p=p, event=event)
c.outerUpdate()
#@+node:ekr.20110605121601.17894: *5* qtree.onIconBoxDoubleClick
def OnBodyClick (self,event=None):
try:
c = self.c ; p = c.currentPosition()
if not g.doHook("bodyclick1",c=c,p=p,v=p,event=event):
self.OnActivateBody(event=event)
c.k.showStateAndMode(w=c.frame.body.bodyCtrl)
g.doHook("bodyclick2",c=c,p=p,v=p,event=event)
except:
g.es_event_exception("bodyclick")
def drawText(self,p,x,y):
"""draw text for position p at nominal coordinates x,y."""
assert(p)
c = self.c
x += self.text_indent
data = g.doHook("draw-outline-text-box",tree=self,c=c,p=p,v=p,x=x,y=y)
if data is not None: return data
self.newText(p,x,y+self.lineyoffset)
self.configureTextState(p)
return self.line_height
#@-node:ekr.20080112145409.360:drawText
def handleSpecialMenus(self, name, parentName, alt_name=None, table=None):
"""
Handle a special menu if name is the name of a special menu.
return True if this method handles the menu.
"""
c = self.c
if table is None: table = []
name2 = name.replace('&', '').replace(' ', '').lower()
if name2 == 'plugins':
# Create the plugins menu using a hook.
g.doHook("create-optional-menus", c=c, menu_name=name)
return True
if name2.startswith('recentfiles'):
# Just create the menu.
# createRecentFilesMenuItems will create the contents later.
g.app.recentFilesManager.recentFilesMenuName = alt_name or name
#848
self.createNewMenu(alt_name or name, parentName)
return True
if name2 == 'help' and g.isMac:
helpMenu = self.getMacHelpMenu(table)
return helpMenu is not None
return False
#@+node:ekr.20031218072017.3780: *4* LeoMenu.hasSelection
def onDrag(self,event):
g.trace()
return ###
c = self.c ; p = self.drag_p
if not event: return
c.setLog()
if not self.dragging:
if not g.doHook("drag1",c=c,p=p,v=p,event=event):
self.startDrag(event)
g.doHook("drag2",c=c,p=p,v=p,event=event)
if not g.doHook("dragging1",c=c,p=p,v=p,event=event):
self.onContinueDrag(event)
g.doHook("dragging2",c=c,p=p,v=p,event=event)
#@-node:ekr.20080112145409.395:onDrag
def OnBodyClick (self,event=None):
try:
c = self.c ; p = c.currentPosition()
if not g.doHook("bodyclick1",c=c,p=p,v=p,event=event):
self.OnActivateBody(event=event)
g.doHook("bodyclick2",c=c,p=p,v=p,event=event)
except:
g.es_event_exception("bodyclick")
def drawNode(self,p,x,y):
c = self.c
# g.trace(x,y,p,id(self.canvas))
data = g.doHook("draw-outline-node",tree=self,c=c,p=p,v=p,x=x,y=y)
if data is not None: return data
if 1:
self.lineyoffset = 0
else:
if hasattr(p.v.t,"unknownAttributes"):
self.lineyoffset = p.v.t.unknownAttributes.get("lineYOffset",0)
else:
self.lineyoffset = 0
# Draw the horizontal line.
self.drawLine(p,
x,y+7+self.lineyoffset,
x+self.box_width,y+7+self.lineyoffset)
if self.inVisibleArea(y):
"""Handle right-clicks in the outline.
This is *not* an event handler: it is called from other event handlers."""
# Note: "headrclick" hooks handled by vnode callback routine.
if event != None:
c = self.c
c.setLog()
if not g.doHook("create-popup-menu",c=c,p=p,v=p,event=event):
self.createPopupMenu(event)
if not g.doHook("enable-popup-menu-items",c=c,p=p,v=p,event=event):
self.enablePopupMenuItems(p,event)
if not g.doHook("show-popup-menu",c=c,p=p,v=p,event=event):
self.showPopupMenu(event)
return "break"
#@+node:ekr.20080112145409.410:OnPopupFocusLost
def on_idle(self):
"""Call all idle-time hooks."""
if g.app.idle_time_hooks_enabled:
for frame in g.app.windowList:
c = frame.c
# Do NOT compute c.currentPosition.
# This would be a MAJOR leak of positions.
g.doHook("idle", c=c)
#@+node:ekr.20100908125007.6017: *4* plugins.doHandlersForTag & helper
c.setLog()
if p and not g.doHook("boxclick1",c=c,p=p,v=p,event=event):
c.endEditing()
if p == p1 or self.initialClickExpandsOrContractsNode:
if p.isExpanded(): p.contract()
else: p.expand()
self.select(p)
if c.frame.findPanel:
c.frame.findPanel.handleUserClick(p)
if self.stayInTree:
c.treeWantsFocus()
else:
c.bodyWantsFocus()
g.doHook("boxclick2",c=c,p=p,v=p,event=event)
c.redraw()
#@-node:ekr.20080112145409.387:onClickBoxClick