This is a bug I showed Marc in Boston about the canvas freezing and not displaying the python boxes that I am creating through a MouseListener?'s method. I created an interface CanvasListener? that extends KeyListener?, MouseListener?, MouseMotionListener? and I interact with it through the following code in python to be automatically executed:
from java.awt.event import KeyEvent
from field.core.plugins.history import Templating
from hyposurface.generics import CanvasListener
from field.core.plugins.python import DynamicExtensionPoint
_self.onCanvas_ = DynamicExtensionPoint(CanvasListener)
#_self.enclosingFrame.getCanvas().addMouseListener(_self.onCanvas_.getProxy())
T.addCanvasListener(_self.enclosingFrame, _self.onCanvas_.getProxy())
_a.add = 0
k = _self.onCanvas_.keyPressed
@k
def keyPressed(event):
if (event.getKeyCode() == KeyEvent.VK_C) :
_a.add = 1
k = _self.onCanvas_.keyReleased
@k
def keyReleased(event):
if (event.getKeyCode() == KeyEvent.VK_C):
_a.add = 0
m = _self.onCanvas_.mousePressed
@m
def mousePressed(event):
loc = _self.enclosingFrame.getCurrentMousePosition()
_a.add = event.getClickCount() == 2
print event.getClickCount()==2 and len(allMarked()) !=0
if (_a.add and len(allMarked()) !=0):
mar_ = allMarked().pop()
newElement_ = Templating.simpleCopy(mar_,_self.root)
newElement_.setFrame(Rect(loc.x,loc.y,50,50))
newElement_.name=mar_.name
newElement_.python_noEdit = 1
newElement_.python_source_v = newElement_.python_source_v + "\n_a.series=" + mar_.name
newElement_()
So you can mark a box, and then double click to basically copy the marked element (from any sheet), but it also adds a tag on the bottom of the python_source_v that I use in my code. I found that it only freezes when the first thing I do with the sheet that contains this code is to copy another element.